Update README.md
Browse files
README.md
CHANGED
@@ -72,9 +72,6 @@ Always review and test generated code. This model is for **educational and resea
|
|
72 |
## How to Get Started with the Model
|
73 |
|
74 |
```python
|
75 |
-
import re
|
76 |
-
import time
|
77 |
-
import sys
|
78 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
79 |
from peft import PeftModel
|
80 |
|
@@ -88,17 +85,4 @@ model = PeftModel.from_pretrained(model, adapter_model)
|
|
88 |
prompt = "Write a C program to calculate factorial of a number."
|
89 |
inputs = tokenizer(prompt, return_tensors="pt")
|
90 |
outputs = model.generate(**inputs, max_new_tokens=150)
|
91 |
-
|
92 |
-
text = output[0]['generated_text']
|
93 |
-
match = re.search(r'### Solution:\n```c\n(.*?)```', text, re.S)
|
94 |
-
|
95 |
-
if match:
|
96 |
-
c_code = match.group(1)
|
97 |
-
print("Extracted C Code:\n")
|
98 |
-
for char in c_code:
|
99 |
-
sys.stdout.write(char)
|
100 |
-
sys.stdout.flush()
|
101 |
-
time.sleep(0.02)
|
102 |
-
print()
|
103 |
-
else:
|
104 |
-
print("No C code found.")
|
|
|
72 |
## How to Get Started with the Model
|
73 |
|
74 |
```python
|
|
|
|
|
|
|
75 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
76 |
from peft import PeftModel
|
77 |
|
|
|
85 |
prompt = "Write a C program to calculate factorial of a number."
|
86 |
inputs = tokenizer(prompt, return_tensors="pt")
|
87 |
outputs = model.generate(**inputs, max_new_tokens=150)
|
88 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|