Upload eval_scripts/use_cap_gen.py with huggingface_hub
Browse files- eval_scripts/use_cap_gen.py +20 -0
eval_scripts/use_cap_gen.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, sys
|
| 2 |
+
os.environ.setdefault("ANNULUS_YEAR_OUTPUT","0") # cap 固化默认
|
| 3 |
+
S="/gpfs/radev/scratch/xu_hua/lq62/annulus_v4"; _CV7=S+"/code_v7"; _REPO=os.path.expanduser("~/Annulus")
|
| 4 |
+
for p in [_REPO+"/eval",_REPO+"/nemo/src",_CV7]:
|
| 5 |
+
if os.path.isdir(p):
|
| 6 |
+
if p in sys.path: sys.path.remove(p)
|
| 7 |
+
sys.path.insert(0,p)
|
| 8 |
+
sys.path.insert(0,S)
|
| 9 |
+
import cap_test_eval_arrow as CAP # 用 cap 的 load_model/generate(被 copying=0.96 证过能生成)
|
| 10 |
+
_md = os.environ["CKPT"] # cap.load_model(nemo) 要含 weights/+context/ 的父目录
|
| 11 |
+
if _md.rstrip("/").endswith("/weights"): _md = os.path.dirname(_md.rstrip("/"))
|
| 12 |
+
generate, ht = CAP.load_model(_md, "nemo")
|
| 13 |
+
P=["The Company's total revenue for the fiscal year",
|
| 14 |
+
"Net income increased primarily due to",
|
| 15 |
+
"The consolidated financial statements",
|
| 16 |
+
"The capital of France is"]
|
| 17 |
+
for p in P:
|
| 18 |
+
out = generate(p, max_new_tokens=45) # cap 的原装 generate(greedy)
|
| 19 |
+
print(f"[cap-gen] {p!r} -> {out!r}", flush=True)
|
| 20 |
+
print("CAPGEN_DONE", flush=True)
|