Spaces:
Runtime error
Runtime error
Kumail00Alawa
commited on
Commit
·
a6e1183
1
Parent(s):
fd74b47
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import BloomTokenizerFast, BloomForCausalLM, pipeline
|
2 |
+
|
3 |
+
|
4 |
+
text="اكتب مقالا من عدة أسطر عن الذكاء الصناعي وتطوراته"
|
5 |
+
prompt = f'Instruction:\n{text}\n\nResponse:'
|
6 |
+
|
7 |
+
model = BloomForCausalLM.from_pretrained('Naseej/noon-7b')
|
8 |
+
|
9 |
+
tokenizer = BloomTokenizerFast.from_pretrained('Naseej/noon-7b')
|
10 |
+
|
11 |
+
generation_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
12 |
+
|
13 |
+
# We recommend the provided hyperparameters for generation
|
14 |
+
# But encourage you to try different values
|
15 |
+
response = generation_pipeline(prompt,
|
16 |
+
pad_token_id=tokenizer.eos_token_id,
|
17 |
+
do_sample=False,
|
18 |
+
num_beams=4,
|
19 |
+
max_length=500,
|
20 |
+
top_p=0.1,
|
21 |
+
top_k=20,
|
22 |
+
repetition_penalty = 3.0,
|
23 |
+
no_repeat_ngram_size=3)[0]['generated_text']
|
24 |
+
|
25 |
+
print(response)
|