Sharathhebbar24
commited on
Commit
•
abe390e
1
Parent(s):
e1adb48
Update README.md
Browse files
README.md
CHANGED
@@ -33,13 +33,13 @@ prompt.
|
|
33 |
>>> model_name = "Sharathhebbar24/Instruct_GPT"
|
34 |
>>> model = AutoModelForCausalLM.from_pretrained(model_name)
|
35 |
>>> tokenizer = AutoTokenizer.from_pretrained("gpt2-medium")
|
36 |
-
>>>def
|
37 |
-
>>>
|
38 |
-
>>>
|
39 |
-
>>>
|
40 |
-
>>>
|
41 |
|
42 |
>>> generate_text("Should I Invest in stocks")
|
43 |
|
44 |
-
|
45 |
```
|
|
|
33 |
>>> model_name = "Sharathhebbar24/Instruct_GPT"
|
34 |
>>> model = AutoModelForCausalLM.from_pretrained(model_name)
|
35 |
>>> tokenizer = AutoTokenizer.from_pretrained("gpt2-medium")
|
36 |
+
>>> def generate_text(prompt):
|
37 |
+
>>> inputs = tokenizer.encode(prompt, return_tensors='pt')
|
38 |
+
>>> outputs = mod1.generate(inputs, max_length=64, pad_token_id=tokenizer.eos_token_id)
|
39 |
+
>>> generated = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
40 |
+
>>> return generated[:generated.rfind(".")+1]
|
41 |
|
42 |
>>> generate_text("Should I Invest in stocks")
|
43 |
|
44 |
+
Should I Invest in stocks? Investing in stocks is a great way to diversify your portfolio. You can invest in stocks based on the market's performance, or you can invest in stocks based on the company's performance.
|
45 |
```
|