Update README.md
Browse files
README.md
CHANGED
@@ -39,9 +39,10 @@ device = torch.device("cuda")
|
|
39 |
model = AutoModelForCausalLM.from_pretrained(model_path).to(device, dtype=torch.bfloat16)
|
40 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
41 |
|
42 |
-
def ask_cosmosage(question
|
43 |
-
prompt = f"You are cosmosage, an AI programmed to
|
44 |
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
|
|
45 |
generated_ids = model.generate(input_ids, max_length=1024, do_sample=True, temperature=0.7, top_k=None, pad_token_id=tokenizer.eos_token_id)
|
46 |
generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
47 |
answer = generated_text.split("ASSISTANT:")[-1]
|
@@ -125,6 +126,18 @@ heavy specialization in cosmology has not come at much of a cost on general-purp
|
|
125 |
is GSM8k, which is a collection of grade school math problems. Here, cosmosage performs significantly better
|
126 |
than OpenHermes-2.5-Mistral-7B.
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
## Example output
|
129 |
|
130 |
**User:**
|
|
|
39 |
model = AutoModelForCausalLM.from_pretrained(model_path).to(device, dtype=torch.bfloat16)
|
40 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
41 |
|
42 |
+
def ask_cosmosage(question):
|
43 |
+
prompt = f"You are cosmosage, an AI programmed to provide excellent and detailed answers to the user's question. You are an expert cosmology assistant, able to answer questions on the cosmic microwave background, galaxy formation, large scale structure, theoretical cosmology, inflation, big bang nucleosynthesis, cosmology instrumentation, and other related topics. Please assume the user is fluent in scientific terminology. Elaborate where possible to give a complete answer. If you do not know, say you do not know.▁ USER: {question}▁ ASSISTANT:"
|
44 |
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
45 |
+
print(input_ids)
|
46 |
generated_ids = model.generate(input_ids, max_length=1024, do_sample=True, temperature=0.7, top_k=None, pad_token_id=tokenizer.eos_token_id)
|
47 |
generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
48 |
answer = generated_text.split("ASSISTANT:")[-1]
|
|
|
126 |
is GSM8k, which is a collection of grade school math problems. Here, cosmosage performs significantly better
|
127 |
than OpenHermes-2.5-Mistral-7B.
|
128 |
|
129 |
+
## Instruction format
|
130 |
+
|
131 |
+
cosmosage_v2 was trained with the "inst" chat template as implemented in axolotl v0.4.0. This resulted in an
|
132 |
+
unusual instruction format:
|
133 |
+
```raw
|
134 |
+
<s> {system prompt}▁ USER: {question}▁ ASSISTANT:
|
135 |
+
```
|
136 |
+
Note the use of the U+2581 Lower One Eighth Block Unicode Character to separate the different sections. The
|
137 |
+
example code in the Usage section above correctly implements this format.
|
138 |
+
|
139 |
+
Fortunately, cosmosage_v2 does not appear to be too sensitive to deviations from this format.
|
140 |
+
|
141 |
## Example output
|
142 |
|
143 |
**User:**
|