Update README.md
Browse files
README.md
CHANGED
@@ -57,4 +57,41 @@ outputs = pipe(
|
|
57 |
min_p=0
|
58 |
)
|
59 |
print(outputs[0]["generated_text"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
```
|
|
|
57 |
min_p=0
|
58 |
)
|
59 |
print(outputs[0]["generated_text"])
|
60 |
+
```
|
61 |
+
|
62 |
+
Also, this repository contains GGUF format model files and provides only the q4_k_m model.
|
63 |
+
|
64 |
+
Please download the GGUF format model file from the repository and place it in the same directory, then execute the following code.
|
65 |
+
# Usage
|
66 |
+
```python
|
67 |
+
from llama_cpp import Llama
|
68 |
+
|
69 |
+
llm = Llama(model_path="TinyLlama-1.1B-Chat-v1.0-PCD250k_v0.1_Q4_K_M.gguf", verbose=False,n_ctx=2000,n_gpu_layers=-1)
|
70 |
+
|
71 |
+
system_message = "You are a chatbot who can help code!"
|
72 |
+
text = '''Create a program that determines whether a given year is a leap year or not.
|
73 |
+
The input is an integer Y (1000 ≤ Y ≤ 2999) representing a year, provided in a single line.
|
74 |
+
Output "YES" if the given year is a leap year, otherwise output "NO" in a single line.
|
75 |
+
A leap year is determined according to the following rules:
|
76 |
+
Rule 1: A year divisible by 4 is a leap year.
|
77 |
+
Rule 2: A year divisible by 100 is not a leap year.
|
78 |
+
Rule 3: A year divisible by 400 is a leap year.
|
79 |
+
Rule 4: If none of the above rules (Rule 1-3) apply, the year is not a leap year.
|
80 |
+
If a year satisfies multiple rules, the rule with the higher number takes precedence.
|
81 |
+
'''
|
82 |
+
texts = f"Translate the following problem statement into Python code. :\n{text}"
|
83 |
+
prompt = f"<|system|>\n{system_message}</s>\n<|user|>\n{texts}</s>\n<|assistant|>\n"
|
84 |
+
output = llm(
|
85 |
+
prompt,
|
86 |
+
stop=["</s>"],
|
87 |
+
max_tokens=512,
|
88 |
+
echo=True,
|
89 |
+
top_k=50,
|
90 |
+
top_p=1.0,
|
91 |
+
temperature=0.1,
|
92 |
+
min_p=0,
|
93 |
+
repeat_penalty=1.0,
|
94 |
+
typical_p=1.0
|
95 |
+
)
|
96 |
+
print(output['choices'][0]["text"])
|
97 |
```
|