Praise2112 commited on
Commit
505d21a
1 Parent(s): 2d74d6c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -0
README.md CHANGED
@@ -1,3 +1,22 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ ``` python
6
+ import ctranslate2
7
+ import transformers
8
+
9
+ generator = ctranslate2.Generator("Praise2112/Mistral-7B-v0.1-int8-ct2", device="cuda", compute_type="int8") # GPU
10
+ # generator = ctranslate2.Generator("Praise2112/Mistral-7B-v0.1-int8-ct2", device="cpu", compute_type="int8") #CPU
11
+ tokenizer = transformers.AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
12
+
13
+ # Unconditional generation.
14
+ start_tokens = [tokenizer.bos_token]
15
+ results = generator.generate_batch([start_tokens], max_length=30, sampling_topk=10)
16
+ print(tokenizer.decode(results[0].sequences_ids[0]))
17
+
18
+ # Conditional generation.
19
+ start_tokens = tokenizer.convert_ids_to_tokens(tokenizer.encode("It is"))
20
+ results = generator.generate_batch([start_tokens], max_length=30, sampling_topk=10)
21
+ print(tokenizer.decode(results[0].sequences_ids[0]))
22
+ ```