--- license: apache-2.0 base_model: bn22/Mistral-7B-Instruct-v0.1-sharded tags: - generated_from_trainer model-index: - name: outputs results: [] --- # UrduNewsMistral7B This model is a fine-tuned version of [bn22/Mistral-7B-Instruct-v0.1-sharded](https://huggingface.co/bn22/Mistral-7B-Instruct-v0.1-sharded) on [Urdu-Instruct-News-Article-Generation](https://huggingface.co/datasets/AhmadMustafa/Urdu-Instruct-News-Article-Generation) dataset. It achieves the following results on the evaluation set: - Loss: 1.1925 ## Usage Here is an example of how you would load: ```python import torch from peft import PeftModel from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig model_name = "bn22/Mistral-7B-Instruct-v0.1-sharded" adapters_name = 'mwz/UrduNewsMistral7B' model = AutoModelForCausalLM.from_pretrained( model_name, load_in_4bit=True, torch_dtype=torch.bfloat16, device_map="auto", max_memory= {i: '24000MB' for i in range(torch.cuda.device_count())}, quantization_config=BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_use_double_quant=True, bnb_4bit_quant_type='nf4' ), ) model = PeftModel.from_pretrained(model, adapters_name) tokenizer = AutoTokenizer.from_pretrained(model_name) ``` Inference can then be performed as usual with HF models as follows: ```python prompt = "پیٹرول کی قیمت میں 2روپے 50 پیسے اضافہ" formatted_prompt = ( f"اس دی گی ایک خبر سے متعلق ایک مضمون لکھیں" f"### Human: {prompt} ### Assistant:" ) inputs = tokenizer(formatted_prompt, return_tensors="pt").to("cuda:0") outputs = model.generate(inputs=inputs.input_ids, max_new_tokens=20) print(tokenizer.decode(outputs[0], skip_special_tokens=True)) ``` Expected output similar to the following: ``` اس دی گی ایک خبر سے متعلق ایک مضمون لکھیں۔ خبر:### Human: پیٹرول کی قیمت میں 2روپے 50 پیسے اضافہ ### Assistant: بہترین پیٹرول کے ان ``` ## Training procedure ### Training hyperparameters The following hyperparameters were used during training: - learning_rate: 0.0002 - train_batch_size: 16 - eval_batch_size: 8 - seed: 42 - gradient_accumulation_steps: 4 - total_train_batch_size: 64 - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08 - lr_scheduler_type: cosine - lr_scheduler_warmup_ratio: 0.05 - num_epochs: 50 - mixed_precision_training: Native AMP ### Training results | Training Loss | Epoch | Step | Validation Loss | |:-------------:|:-----:|:----:|:---------------:| | 1.1387 | 5.71 | 10 | 1.2070 | | 0.9337 | 11.43 | 20 | 1.1634 | | 0.8676 | 17.14 | 30 | 1.1697 | | 0.8065 | 22.86 | 40 | 1.1868 | | 0.7759 | 28.57 | 50 | 1.1925 | ### Framework versions - Transformers 4.36.0.dev0 - Pytorch 2.1.0+cu121 - Datasets 2.15.0 - Tokenizers 0.15.0