Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
Usage:
|
| 5 |
+
```
|
| 6 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 7 |
+
import torch
|
| 8 |
+
import json
|
| 9 |
+
|
| 10 |
+
title: str = "your project title here"
|
| 11 |
+
summary: str = "your summary here"
|
| 12 |
+
model_name: str = "Lux-In-Tenebris/research_summary_deconstructor"
|
| 13 |
+
|
| 14 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 15 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, dtype=torch.bfloat16).to(device)
|
| 16 |
+
tokenizer = AutoTokenizer(model_name)
|
| 17 |
+
model.eval()
|
| 18 |
+
|
| 19 |
+
input_dict = {"title": title, "summary": summary}
|
| 20 |
+
inputs = tokenizer(json.dumps(input_dict, ensure_ascii=False), return_tensors="pt", truncation=False, padding=False).to(device)
|
| 21 |
+
|
| 22 |
+
with torch.no_grad():
|
| 23 |
+
outputs = model.generate(**inputs, max_new_tokens=8_192, temperature=1.0, do_sample=True)
|
| 24 |
+
generated_tokens = outputs[0][[inputs["input_ids"].shape[1]:]
|
| 25 |
+
decoded = tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
| 26 |
+
```
|