akameswa commited on
Commit
b4862e9
1 Parent(s): 386c7b0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -1
README.md CHANGED
@@ -32,4 +32,32 @@ experts:
32
  positive_prompts: ["You are helpful a coding assistant good at cpp"]
33
  - source_model: akameswa/mistral-7b-instruct-python-16bit
34
  positive_prompts: ["You are helpful a coding assistant good at python"]
35
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  positive_prompts: ["You are helpful a coding assistant good at cpp"]
33
  - source_model: akameswa/mistral-7b-instruct-python-16bit
34
  positive_prompts: ["You are helpful a coding assistant good at python"]
35
+ ```
36
+
37
+ ## Inference
38
+ ```python
39
+ from transformers import AutoTokenizer
40
+ import transformers
41
+ import torch
42
+
43
+ model = "akameswa/mixtral-4x7b-instruct-code-trial"
44
+ messages = [{"role": "user", "content": "What is a large language model?"}]
45
+
46
+ tokenizer = AutoTokenizer.from_pretrained(model)
47
+ prompt = tokenizer.apply_chat_template(
48
+ messages,
49
+ tokenize=False,
50
+ add_generation_prompt=True
51
+ )
52
+ pipeline = transformers.pipeline(
53
+ "text-generation",
54
+ model=model,
55
+ torch_dtype=torch.float16,
56
+ device_map="auto",
57
+ model_kwargs={"load_in_4bit": True},
58
+ )
59
+
60
+ outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
61
+ ```
62
+
63
+ * [Link to inference notebook](https://github.com/akameswa/CodeGenerationMoE/blob/main/code/inference_moe.ipynb)