LimYeri commited on
Commit
c9c724d
1 Parent(s): b48a439

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -0
README.md CHANGED
@@ -43,6 +43,33 @@ To use the CodeMind model, you can access it through the Hugging Face model hub
43
  Please refer to the documentation and examples for detailed instructions on how to integrate and use the CodeMind model effectively.
44
 
45
  Below we share some code snippets on how to get quickly started with running the model. After downloading the transformers library via 'pip install -U transformers', use the following snippet code.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  #### Running the model on a single / multi GPU
48
 
 
43
  Please refer to the documentation and examples for detailed instructions on how to integrate and use the CodeMind model effectively.
44
 
45
  Below we share some code snippets on how to get quickly started with running the model. After downloading the transformers library via 'pip install -U transformers', use the following snippet code.
46
+ #### Running the model on a CPU
47
+
48
+ ```python
49
+ from transformers import AutoTokenizer, AutoModelForCausalLM
50
+
51
+ model = AutoModelForCausalLM.from_pretrained("LimYeri/CodeMind-Gemma-7B-QLoRA-4bit")
52
+ tokenizer = AutoTokenizer.from_pretrained("LimYeri/CodeMind-Gemma-7B-QLoRA-4bit")
53
+
54
+ def get_completion(query: str, model, tokenizer) -> str:
55
+ prompt_template = """
56
+ <start_of_turn>user
57
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
58
+ {query}
59
+ <end_of_turn>\n\n<start_of_turn>model
60
+
61
+ """
62
+ prompt = prompt_template.format(query=query)
63
+ encodeds = tokenizer(prompt, return_tensors="pt", add_special_tokens=True)
64
+ generated_ids = model.generate(**encodeds, max_new_tokens=1000, do_sample=True, pad_token_id=tokenizer.eos_token_id)
65
+ # decoded = tokenizer.batch_decode(generated_ids)
66
+ decoded = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
67
+ return (decoded)
68
+
69
+ result = get_completion(query="Tell me how to solve the Leetcode Two Sum problem", model=model, tokenizer=tokenizer)
70
+ print(result)
71
+
72
+ ```
73
 
74
  #### Running the model on a single / multi GPU
75