migtissera commited on
Commit
520780d
·
verified ·
1 Parent(s): 4e80ea7

Update README.md

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