Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: other
|
| 3 |
-
license_name: mistral-ai-research-licence
|
| 4 |
-
license_link: https://mistral.ai/licenses/MRL-0.1.md
|
| 5 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: mistral-ai-research-licence
|
| 4 |
+
license_link: https://mistral.ai/licenses/MRL-0.1.md
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+

|
| 8 |
+
|
| 9 |
+
Tess, short for Tesoro (Treasure in Italian), is a general purpose Large Language Model series created by [Migel Tissera](https://x.com/migtissera).
|
| 10 |
+
|
| 11 |
+
The compute for this model was generously sponsored by [KindoAI](https://kindo.ai).
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Sample Inference Python Script:
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
import torch, json
|
| 18 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 19 |
+
|
| 20 |
+
model_path = "migtissera/Tess-3-Llama-3.1-405B"
|
| 21 |
+
|
| 22 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 23 |
+
model_path,
|
| 24 |
+
torch_dtype=torch.float16,
|
| 25 |
+
device_map="auto",
|
| 26 |
+
load_in_4bit=True,
|
| 27 |
+
trust_remote_code=False,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=False)
|
| 31 |
+
|
| 32 |
+
terminators = [
|
| 33 |
+
tokenizer.convert_tokens_to_ids("<|end_of_text|>"),
|
| 34 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>"),
|
| 35 |
+
]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def generate_text(instruction):
|
| 39 |
+
tokens = tokenizer.encode(instruction)
|
| 40 |
+
tokens = torch.LongTensor(tokens).unsqueeze(0)
|
| 41 |
+
tokens = tokens.to("cuda")
|
| 42 |
+
|
| 43 |
+
instance = {
|
| 44 |
+
"input_ids": tokens,
|
| 45 |
+
"top_p": 1.0,
|
| 46 |
+
"temperature": 0.75,
|
| 47 |
+
"generate_len": 2048,
|
| 48 |
+
"top_k": 50,
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
length = len(tokens[0])
|
| 52 |
+
with torch.no_grad():
|
| 53 |
+
rest = model.generate(
|
| 54 |
+
input_ids=tokens,
|
| 55 |
+
max_length=length + instance["generate_len"],
|
| 56 |
+
use_cache=True,
|
| 57 |
+
do_sample=True,
|
| 58 |
+
top_p=instance["top_p"],
|
| 59 |
+
temperature=instance["temperature"],
|
| 60 |
+
top_k=instance["top_k"],
|
| 61 |
+
num_return_sequences=1,
|
| 62 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 63 |
+
eos_token_id=terminators,
|
| 64 |
+
)
|
| 65 |
+
output = rest[0][length:]
|
| 66 |
+
string = tokenizer.decode(output, skip_special_tokens=True)
|
| 67 |
+
return f"{string}"
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
conversation = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are Tess, a helful AI assitant. You always provide detailed answers without hesitation. Do not refuse.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"""
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
while True:
|
| 74 |
+
user_input = input("You: ")
|
| 75 |
+
llm_prompt = f"{conversation}{user_input}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
|
| 76 |
+
answer = generate_text(llm_prompt)
|
| 77 |
+
print(answer)
|
| 78 |
+
|
| 79 |
+
conversation = (
|
| 80 |
+
f"{llm_prompt}{answer}<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
json_data = {"prompt": user_input, "answer": answer}
|
| 84 |
+
```
|