charlieoneill
commited on
Commit
•
f14e8d2
1
Parent(s):
bc74fd3
Update README.md
Browse files
README.md
CHANGED
@@ -11,6 +11,49 @@ It was fine-tuned on several thousand astronomy abstracts collected on Arxiv.
|
|
11 |
|
12 |
## Model Details
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
### Model Description
|
15 |
|
16 |
<!-- Provide a longer summary of what this model is. -->
|
|
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
+
```{python}
|
15 |
+
from transformers import AutoModelForCausalLM
|
16 |
+
|
17 |
+
online_model = AutoModelForCausalLM.from_pretrained("charlieoneill/falcon-7b-abstracts-2190", trust_remote_code=True)
|
18 |
+
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-7b")
|
20 |
+
pipeline = transformers.pipeline(
|
21 |
+
"text-generation",
|
22 |
+
model=online_model,
|
23 |
+
tokenizer=tokenizer,
|
24 |
+
torch_dtype=torch.bfloat16,
|
25 |
+
trust_remote_code=True,
|
26 |
+
device_map="auto",
|
27 |
+
)
|
28 |
+
|
29 |
+
sequences = pipeline(
|
30 |
+
"### Instruction: Generate a scientific hypothesis about astronomy in the style of an Arxiv paper.\n ### Hypothesis:",
|
31 |
+
max_length=500,
|
32 |
+
do_sample=True,
|
33 |
+
top_k=10,
|
34 |
+
num_return_sequences=1,
|
35 |
+
eos_token_id=tokenizer.eos_token_id,
|
36 |
+
)
|
37 |
+
|
38 |
+
def format_output(output):
|
39 |
+
output = output.replace("\n", " ") # Replace newline characters with spaces
|
40 |
+
output = output.replace("\\n", " ")
|
41 |
+
parts = output.split("###") # Split string at '###'
|
42 |
+
|
43 |
+
# Get and clean instruction part
|
44 |
+
instruction = parts[1].strip()
|
45 |
+
|
46 |
+
# Get and clean hypothesis part
|
47 |
+
hypothesis = parts[2].strip()
|
48 |
+
|
49 |
+
# Format the output
|
50 |
+
formatted_output = f"{instruction}\n\n{hypothesis}"
|
51 |
+
|
52 |
+
return formatted_output
|
53 |
+
|
54 |
+
format_output(sequences[0]['generated_text'])
|
55 |
+
```
|
56 |
+
|
57 |
### Model Description
|
58 |
|
59 |
<!-- Provide a longer summary of what this model is. -->
|