migtissera commited on
Commit
63513c3
1 Parent(s): 53775a9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +82 -1
README.md CHANGED
@@ -1 +1,82 @@
1
- hello
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ base_model: mistralai/Codestral-22B-v0.1
4
+ tags:
5
+ - generated_from_trainer
6
+ model-index:
7
+ - name: home/ubuntu/trinity-codestral-1
8
+ results: []
9
+ ---
10
+
11
+
12
+ ![Trinity](https://huggingface.co/migtissera/Trinity-13B-v1.0/resolve/main/Trinity.png)
13
+
14
+ Trinity is a coding specific Large Language Model series created by [Migel Tissera](https://x.com/migtissera).
15
+
16
+
17
+ # Prompt Format
18
+ ChatML
19
+
20
+ # Sample Inference Python Script:
21
+
22
+ ```python
23
+ import torch, json
24
+ from transformers import AutoModelForCausalLM, AutoTokenizer
25
+
26
+ model_path = "migtissera/Trinity-2-Codestral-22B-v0.2"
27
+
28
+ model = AutoModelForCausalLM.from_pretrained(
29
+ model_path,
30
+ torch_dtype=torch.float16,
31
+ device_map="auto",
32
+ load_in_4bit=True,
33
+ trust_remote_code=False,
34
+ )
35
+
36
+ tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=False)
37
+
38
+ terminators = [tokenizer.convert_tokens_to_ids("<|im_end|>")]
39
+
40
+
41
+ def generate_text(instruction):
42
+ tokens = tokenizer.encode(instruction)
43
+ tokens = torch.LongTensor(tokens).unsqueeze(0)
44
+ tokens = tokens.to("cuda")
45
+
46
+ instance = {
47
+ "input_ids": tokens,
48
+ "top_p": 1.0,
49
+ "temperature": 0.75,
50
+ "generate_len": 2048,
51
+ "top_k": 50,
52
+ }
53
+
54
+ length = len(tokens[0])
55
+ with torch.no_grad():
56
+ rest = model.generate(
57
+ input_ids=tokens,
58
+ max_length=length + instance["generate_len"],
59
+ use_cache=True,
60
+ do_sample=True,
61
+ top_p=instance["top_p"],
62
+ temperature=instance["temperature"],
63
+ top_k=instance["top_k"],
64
+ num_return_sequences=1,
65
+ pad_token_id=tokenizer.eos_token_id,
66
+ eos_token_id=terminators,
67
+ )
68
+ output = rest[0][length:]
69
+ string = tokenizer.decode(output, skip_special_tokens=True)
70
+ return f"{string}"
71
+
72
+
73
+
74
+ 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"""
75
+
76
+ while True:
77
+ user_input = input("You: ")
78
+ llm_prompt = f"{conversation}{user_input}<|im_end|>\n<|im_start|>assistant\n"
79
+ answer = generate_text(llm_prompt)
80
+ print(answer)
81
+ conversation = f"{llm_prompt}{answer}<|im_end|>\n<|im_start|>user\n"
82
+ ```