Update README.md
Browse files
README.md
CHANGED
@@ -37,11 +37,19 @@ This gemma model was trained 2x faster with [Unsloth](https://github.com/unsloth
|
|
37 |
### Running Model:
|
38 |
|
39 |
```python
|
|
|
40 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
41 |
|
|
|
|
|
|
|
|
|
42 |
tokenizer = AutoTokenizer.from_pretrained("pmking27/PrathameshLLM-7B")
|
|
|
|
|
43 |
model = AutoModelForCausalLM.from_pretrained("pmking27/PrathameshLLM-7B")
|
44 |
|
|
|
45 |
alpaca_prompt = """
|
46 |
### Instruction:
|
47 |
{}
|
@@ -52,11 +60,15 @@ alpaca_prompt = """
|
|
52 |
### Response:
|
53 |
{}"""
|
54 |
|
55 |
-
|
|
|
56 |
[
|
57 |
alpaca_prompt.format(
|
58 |
-
'''
|
|
|
|
|
59 |
context:
|
|
|
60 |
General elections will be held in India from 19 April 2024 to 1 June 2024 to elect the 543 members of the 18th Lok Sabha. The elections will be held in seven phases and the results will be announced on 4 June 2024. This will be the largest-ever election in the world, surpassing the 2019 Indian general election, and will be the longest-held general elections in India with a total span of 44 days (excluding the first 1951–52 Indian general election). The incumbent prime minister Narendra Modi who completed a second term will be contesting elections for a third consecutive term.
|
61 |
|
62 |
Approximately 960 million individuals out of a population of 1.4 billion are eligible to participate in the elections, which are expected to span a month for completion. The Legislative assembly elections in the states of Andhra Pradesh, Arunachal Pradesh, Odisha, and Sikkim will be held simultaneously with the general election, along with the by-elections for 35 seats among 16 states.
|
@@ -64,29 +76,33 @@ inputs = tokenizer(
|
|
64 |
"भारतातील सार्वत्रिक निवडणुका किती टप्प्यात पार पडतील?", # input
|
65 |
"", # output - leave this blank for generation!
|
66 |
)
|
67 |
-
], return_tensors = "pt")
|
68 |
-
outputs = model.generate(**inputs, max_new_tokens = 100)
|
69 |
-
result=tokenizer.batch_decode(outputs)[0]
|
70 |
-
print(result)
|
71 |
-
```
|
72 |
|
73 |
-
|
|
|
|
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
You're an assistant trained to answer questions using the given context.
|
79 |
-
context:
|
80 |
-
General elections will be held in India from 19 April 2024 to 1 June 2024 to elect the 543 members of the 18th Lok Sabha. The elections will be held in seven phases and the results will be announced on 4 June 2024. This will be the largest-ever election in the world, surpassing the 2019 Indian general election, and will be the longest-held general elections in India with a total span of 44 days (excluding the first 1951–52 Indian general election). The incumbent prime minister Narendra Modi who completed a second term will be contesting elections for a third consecutive term.
|
81 |
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
84 |
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
```
|
91 |
|
92 |
|
|
|
37 |
### Running Model:
|
38 |
|
39 |
```python
|
40 |
+
# Importing necessary modules
|
41 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
42 |
|
43 |
+
# Setting the device to load the model onto (assuming GPU availability)
|
44 |
+
device = 'cuda'
|
45 |
+
|
46 |
+
# Loading the tokenizer for the model
|
47 |
tokenizer = AutoTokenizer.from_pretrained("pmking27/PrathameshLLM-7B")
|
48 |
+
|
49 |
+
# Loading the pre-trained model
|
50 |
model = AutoModelForCausalLM.from_pretrained("pmking27/PrathameshLLM-7B")
|
51 |
|
52 |
+
# Defining the Alpaca prompt template
|
53 |
alpaca_prompt = """
|
54 |
### Instruction:
|
55 |
{}
|
|
|
60 |
### Response:
|
61 |
{}"""
|
62 |
|
63 |
+
# Providing the input to the model
|
64 |
+
model_inputs = tokenizer(
|
65 |
[
|
66 |
alpaca_prompt.format(
|
67 |
+
'''
|
68 |
+
You're an assistant trained to answer questions using the given context.
|
69 |
+
|
70 |
context:
|
71 |
+
|
72 |
General elections will be held in India from 19 April 2024 to 1 June 2024 to elect the 543 members of the 18th Lok Sabha. The elections will be held in seven phases and the results will be announced on 4 June 2024. This will be the largest-ever election in the world, surpassing the 2019 Indian general election, and will be the longest-held general elections in India with a total span of 44 days (excluding the first 1951–52 Indian general election). The incumbent prime minister Narendra Modi who completed a second term will be contesting elections for a third consecutive term.
|
73 |
|
74 |
Approximately 960 million individuals out of a population of 1.4 billion are eligible to participate in the elections, which are expected to span a month for completion. The Legislative assembly elections in the states of Andhra Pradesh, Arunachal Pradesh, Odisha, and Sikkim will be held simultaneously with the general election, along with the by-elections for 35 seats among 16 states.
|
|
|
76 |
"भारतातील सार्वत्रिक निवडणुका किती टप्प्यात पार पडतील?", # input
|
77 |
"", # output - leave this blank for generation!
|
78 |
)
|
79 |
+
], return_tensors = "pt")
|
|
|
|
|
|
|
|
|
80 |
|
81 |
+
# Moving model inputs to the specified device
|
82 |
+
model_inputs.to(device)
|
83 |
+
model.to(device)
|
84 |
|
85 |
+
# Generating responses from the model
|
86 |
+
outputs = model.generate(**model_inputs, max_new_tokens=100)
|
87 |
+
decoded_output = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
|
|
|
|
|
|
|
88 |
|
89 |
+
# Finding the start and end positions of the response
|
90 |
+
start_marker = "### Response:"
|
91 |
+
end_marker = "<eos>"
|
92 |
+
start_pos = decoded_output.find(start_marker) + len(start_marker)
|
93 |
+
end_pos = decoded_output.find(end_marker, start_pos)
|
94 |
|
95 |
+
# Extracting the response text
|
96 |
+
response_text = decoded_output[start_pos:end_pos].strip()
|
97 |
|
98 |
+
print(response_text)
|
99 |
+
|
100 |
+
```
|
101 |
+
|
102 |
+
### Output:
|
103 |
+
|
104 |
+
```markdown
|
105 |
+
भारतातील सार्वत्रिक निवडणुका 7 टप्प्यांमध्ये पार पडतील.
|
106 |
```
|
107 |
|
108 |
|