transformers pytorch llama text-generation en autotrain_compatible endpoints_compatible text-generation-inference region:us
---
language:
- en
library_name: transformers
pipeline_tag: text-generation
---

This model is for the module
# Initial Knowledge Assessment Test Generation

## Steps
- Data was gathered by:
  - Downloading youtube playlists for each course from every category
  - The videos were transcribed
  - The text was fed to chatgpt via API, to formulate prompts n reponse pairs. 
- 7 Billion parameter LLama 2 model by [NousResearch](https://huggingface.co/NousResearch/Llama-2-7b-chat-hf) was finetuned on the curated data.

## How to use the model?
### Note the format of the prompt. Only change the text in the variable "paragraph". This is the text which acts as the context for the generated test./
```
# Use a huggingafce pipeline as a high-level helper
from transformers import pipeline
import torch
pipe = pipeline("text-generation",
                  model="SalehAhmad/Initial_Knowledge_Assessment_Test-Model-LLAMA7B_3Epochs",
                  device=torch.device('cuda' if torch.cuda.is_available() else 'cpu'),
                  torch_dtype=torch.bfloat16,
                  max_new_tokens=1024)

paragraph = '''Computer science theories and basic programming principles form the foundation of the ever-evolving field of technology. At its core, computer science is not just about writing code but involves the exploration and application of fundamental principles that underpin the design and functioning of computers. One key theory in computer science is the Turing Machine, proposed by Alan Turing in the 1930s. This theoretical construct laid the groundwork for understanding the limits and possibilities of computation. The idea that any computable function could be computed by a Turing Machine provided a theoretical framework for the development of modern computers.
Another essential theory in computer science is the concept of algorithms. Algorithms are step-by-step procedures or formulas for solving problems and performing tasks. They are crucial in programming as they guide the computer in executing tasks efficiently. The study of algorithms involves analyzing their efficiency and correctness, and it plays a pivotal role in designing software that can handle large datasets and complex computations. Moreover, algorithms are closely related to data structures, which are the ways in which data is organized and stored in a computer's memory. Efficient data structures are essential for optimizing the performance of algorithms.'''

prompt = f'''<s> [INST] You are a chatbot, who is helping to curate datasets. Based on the input paragraph as context generate only one mcq question. You donot generate repetitive questions.
When you are given a paragraph for context. You will generate only one mcq question, it's 4 options and it's actual answer.
For Example:
Paragraph: .....
-Start of Question-
Question: ......
Options: 
a) .....
b) .....
c) .....
d) .....
Actual Answer: b)....
-End of Question-
-Start of Question-
Question: ......
Options: 
a) .....
b) .....
c) .....
d) .....
Actual Answer: d)....
-End of Question-
and so on.
Paragraph: {paragraph}
 [/INST]</s>Response:'''

output = pipe(prompt, 
              num_return_sequences=1, 
              return_full_text=False)

print(output[0]['generated_text'])
```