Text Generation
Transformers
PyTorch
Telugu
English
llama
conversational
text-generation-inference
Inference Endpoints
Telugu-LLM-Labs commited on
Commit
b8e2895
1 Parent(s): 5c5a9ce

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -8
README.md CHANGED
@@ -26,6 +26,9 @@ This model is based on [Telugu-Llama2-7B-v0-Base](https://huggingface.co/Telugu-
26
  ```
27
 
28
  # Usage
 
 
 
29
  ```python3
30
  import torch
31
  from transformers import AutoTokenizer, AutoModelForCausalLM
@@ -37,33 +40,59 @@ model_name = "Telugu-LLM-Labs/Telugu-Llama2-7B-v0-Instruct"
37
  tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side="right")
38
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16).to(device)
39
 
 
 
 
40
  text = f"""Instruction: {instruction} \nInput: {input} \nResponse:"""
41
 
42
  encodings = tokenizer(text, padding=True, return_tensors="pt")
43
  encodings = encodings.to(device)
44
 
45
  with torch.inference_mode():
46
- outputs = model.generate(encodings.input_ids, do_sample=False, max_new_tokens=100)
47
 
48
  output = tokenizer.batch_decode(outputs.detach(), skip_special_tokens=True)
49
  ```
50
 
51
- ## Examples:
52
-
53
- ### With Romanized Telugu
54
 
55
  ```
56
- instruction = "Krindi samaacharam prakaram google app eppudu release ayyindi?"
57
- input ="Google News is a news aggregator service developed by Google. It presents a continuous flow of links to articles organized from thousands of publishers and magazines. Google News is available as an app on Android, iOS, and the Web. Google released a beta version in September 2002 and the official app in January 2006."
58
  ```
59
 
60
- ### With Native Telugu
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- ```
63
  instruction = "కింది వచనాన్ని సంగ్రహించండి"
64
  input="గూగుల్ వార్తలు అనేది గూగుల్ ద్వారా అభివృద్ధి చేయబడిన వార్తా అగ్రిగేటర్ సేవ. ఇది వేలకొద్దీ ప్రచురణకర్తలు మరియు మ్యాగజైన్‌ల నుండి నిర్వహించబడిన కథనాలకు నిరంతర లింక్‌లను అందిస్తుంది. గూగుల్ వార్తలు Android, iOS మరియు వెబ్‌లో యాప్‌గా అందుబాటులో ఉన్నాయి. గూగుల్ సెప్టెంబరు 2002లో బీటా వెర్షన్‌ను మరియు జనవరి 2006లో అధికారిక యాప్‌ను విడుదల చేసింది."
 
 
 
 
 
 
 
 
 
 
65
  ```
66
 
 
 
 
 
 
67
  # Developers:
68
 
69
  The model is a collaborative effort by [Ravi Theja](https://twitter.com/ravithejads) and [Ramsri Goutham](https://twitter.com/ramsri_goutham). Feel free to DM either of us if you have any questions.
 
26
  ```
27
 
28
  # Usage
29
+
30
+ ## With Romanized Telugu
31
+
32
  ```python3
33
  import torch
34
  from transformers import AutoTokenizer, AutoModelForCausalLM
 
40
  tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side="right")
41
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16).to(device)
42
 
43
+ instruction = "Krindi samaacharam prakaram google app eppudu release ayyindi?"
44
+ input ="Google News is a news aggregator service developed by Google. It presents a continuous flow of links to articles organized from thousands of publishers and magazines. Google News is available as an app on Android, iOS, and the Web. Google released a beta version in September 2002 and the official app in January 2006."
45
+
46
  text = f"""Instruction: {instruction} \nInput: {input} \nResponse:"""
47
 
48
  encodings = tokenizer(text, padding=True, return_tensors="pt")
49
  encodings = encodings.to(device)
50
 
51
  with torch.inference_mode():
52
+ outputs = model.generate(encodings.input_ids, do_sample=False, max_new_tokens=500)
53
 
54
  output = tokenizer.batch_decode(outputs.detach(), skip_special_tokens=True)
55
  ```
56
 
57
+ ### Sample Output:
 
 
58
 
59
  ```
60
+ 1. September 2002 Google released a beta version of Google News.
61
+ 2. January 2006 Google released the official version of Google News.
62
  ```
63
 
64
+ ## With Native Telugu
65
+
66
+ ```python3
67
+ import torch
68
+ from transformers import AutoTokenizer, AutoModelForCausalLM
69
+
70
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
71
+
72
+ model_name = "Telugu-LLM-Labs/Telugu-Llama2-7B-v0-Instruct"
73
+
74
+ tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side="right")
75
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16).to(device)
76
 
 
77
  instruction = "కింది వచనాన్ని సంగ్రహించండి"
78
  input="గూగుల్ వార్తలు అనేది గూగుల్ ద్వారా అభివృద్ధి చేయబడిన వార్తా అగ్రిగేటర్ సేవ. ఇది వేలకొద్దీ ప్రచురణకర్తలు మరియు మ్యాగజైన్‌ల నుండి నిర్వహించబడిన కథనాలకు నిరంతర లింక్‌లను అందిస్తుంది. గూగుల్ వార్తలు Android, iOS మరియు వెబ్‌లో యాప్‌గా అందుబాటులో ఉన్నాయి. గూగుల్ సెప్టెంబరు 2002లో బీటా వెర్షన్‌ను మరియు జనవరి 2006లో అధికారిక యాప్‌ను విడుదల చేసింది."
79
+
80
+ text = f"""Instruction: {instruction} \nInput: {input} \nResponse:"""
81
+
82
+ encodings = tokenizer(text, padding=True, return_tensors="pt")
83
+ encodings = encodings.to(device)
84
+
85
+ with torch.inference_mode():
86
+ outputs = model.generate(encodings.input_ids, do_sample=False, max_new_tokens=500)
87
+
88
+ output = tokenizer.batch_decode(outputs.detach(), skip_special_tokens=True)
89
  ```
90
 
91
+ ### Sample Output:
92
+
93
+ 1. గూగుల్ వార్తలు అనేది గూగుల్ ద్వారా అభివృద్ధి చేయబడిన వార్తా అగ్రిగేటర్ సేవ, వేలకొద్దీ ప్రచురణకర్తలు మరియు మ్యాగజైన్‌ల నుండి నిర్వహించబడిన కథనాలకు నిరంతర లింక్‌లను అందిస్తుంది.
94
+ 2. గూగుల్ సెప్టెంబరు 2002లో బీటా వెర్షన్ మరియు జనవరి 2006లో అధికారిక యాప్ ను విడుదల చేసింది.
95
+
96
  # Developers:
97
 
98
  The model is a collaborative effort by [Ravi Theja](https://twitter.com/ravithejads) and [Ramsri Goutham](https://twitter.com/ramsri_goutham). Feel free to DM either of us if you have any questions.