DonatePlz commited on
Commit
a891cb1
1 Parent(s): 99869d8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -0
README.md CHANGED
@@ -31,6 +31,40 @@ Overall, the color of the sky is a result of the complex interaction between sun
31
  I hope this explanation helps! Let me know if you have any further questions.
32
  ```
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  # OpenChat 3.5 extended to 16k context length.
36
 
 
31
  I hope this explanation helps! Let me know if you have any further questions.
32
  ```
33
 
34
+ ### Example:
35
+ ```python
36
+ from transformers import AutoModelForCausalLM, AutoTokenizer
37
+ import transformers
38
+ import torch
39
+
40
+ model_id = "DonatePlz/openchat_3.5-16k-merged"
41
+ # model_id = "NurtureAI/openchat_3.5-16k"
42
+
43
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
44
+ model = AutoModelForCausalLM.from_pretrained(
45
+ model_id,
46
+ torch_dtype=torch.float16,
47
+ device_map="auto",
48
+ use_flash_attention_2=True,
49
+ )
50
+ pipeline = transformers.pipeline(
51
+ "text-generation",
52
+ model=model,
53
+ tokenizer=tokenizer,
54
+ )
55
+ instruction = "Why the sky is blue? Explain everything using real science and research."
56
+ prompt = f"GPT4 User: {instruction}<|end_of_turn|>GPT4 Assistant: "
57
+ sequences = pipeline(
58
+ prompt,
59
+ max_new_tokens=500,
60
+ do_sample=False,
61
+ return_full_text=False,
62
+ num_return_sequences=1,
63
+ )
64
+ for seq in sequences:
65
+ print(f"{seq['generated_text']}")
66
+ ```
67
+
68
 
69
  # OpenChat 3.5 extended to 16k context length.
70