|
--- |
|
license: apache-2.0 |
|
pipeline_tag: text-generation |
|
library_name: peft |
|
--- |
|
|
|
## Hindi-wiki-LLaMA |
|
Hindi Wikipedia Article Generation Model |
|
This repository contains a language generation model trained on Hindi Wikipedia articles using the Hugging Face Transformers library. The model is based on the Llama-2 architecture and fine-tuned on a large dataset of Hindi text from Wikipedia. |
|
|
|
## Model Details |
|
|
|
- Base Model: Llama-2 |
|
- Pretraining Dataset: Hindi Wikipedia Articles |
|
- Tokenizer: Hugging Face Tokenizer |
|
- Model Architecture: Causal Language Modeling |
|
|
|
|
|
```python |
|
from peft import AutoPeftModelForCausalLM |
|
|
|
base_model_name = "meta-llama/Llama-2-7b-hf" |
|
tokenizer = AutoTokenizer.from_pretrained(base_model_name, trust_remote_code=True) |
|
tokenizer.pad_token = tokenizer.eos_token |
|
output_dir = "./final_checkpoint" |
|
device_map = {"": 0} |
|
model = AutoPeftModelForCausalLM.from_pretrained(output_dir, device_map=device_map, torch_dtype=torch.bfloat16) |
|
device = torch.device("cuda") |
|
text = "" |
|
inputs = tokenizer(text, return_tensors="pt").to(device) |
|
outputs = model.generate(input_ids=inputs["input_ids"].to("cuda"), attention_mask=inputs["attention_mask"], max_new_tokens=100, pad_token_id=tokenizer.eos_token_id) |
|
|
|
print(tokenizer.decode(outputs[0][len(inputs["input_ids"][0]):], skip_special_tokens=True)) |
|
``` |
|
|
|
## Model Performance:-- |
|
|
|
The model has been trained on a substantial amount of Hindi Wikipedia articles, which allows it to generate coherent and contextually relevant text. |