初始化项目,由ModelHub XC社区提供模型
Model: BirendraSharma/llama3.2_1B_distractors_generation Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
104
README.md
Normal file
104
README.md
Normal file
@@ -0,0 +1,104 @@
|
||||
---
|
||||
library_name: transformers
|
||||
tags:
|
||||
- text-generation
|
||||
- llama
|
||||
- mcq-generation
|
||||
- distractor-generation
|
||||
- safetensors
|
||||
---
|
||||
|
||||
# LLaMA 3.2 1B - Distractors Generation Model
|
||||
|
||||
This model is designed to generate distractors (incorrect but plausible answer choices) for multiple-choice questions. It is particularly useful in educational applications where high-quality distractors are needed.
|
||||
|
||||
## Model Details
|
||||
|
||||
- **Model Name**: `llama3.2_1B_distractors_generation`
|
||||
- **Architecture**: LLaMA 3.2 1B
|
||||
- **Developer**: [BirendraSharma](https://huggingface.co/BirendraSharma)
|
||||
- **Use Case**: MCQ distractor generation
|
||||
- **License**: [More Information Needed]
|
||||
|
||||
## How to Use the Model
|
||||
|
||||
You can load the model and tokenizer using `transformers` and generate distractors using the following example:
|
||||
|
||||
### Installation
|
||||
Ensure you have `transformers` and `torch` installed:
|
||||
```bash
|
||||
pip install transformers torch
|
||||
```
|
||||
|
||||
### Loading the Model & Tokenizer
|
||||
```python
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
|
||||
import torch
|
||||
|
||||
# Load model and tokenizer
|
||||
model_path = "BirendraSharma/llama3.2_1B_distractors_generation"
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
||||
model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16, device_map="auto")
|
||||
|
||||
def generate_distractors(context, question, answer, instruction, model, tokenizer, max_seq_length=1024):
|
||||
"""Generates distractors for a given question-answer pair."""
|
||||
model.eval()
|
||||
prompt = f"""{instruction}
|
||||
Context: '{context}'
|
||||
Question: '{question}'
|
||||
Answer: '{answer}'.
|
||||
Provide only three distractors as a comma-separated list. Do not include explanations, commentary, or additional text."""
|
||||
|
||||
inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True, max_length=max_seq_length).to("cuda")
|
||||
|
||||
generation_config = GenerationConfig(
|
||||
max_new_tokens=128,
|
||||
use_cache=True,
|
||||
temperature=0.7,
|
||||
)
|
||||
|
||||
outputs = model.generate(**inputs, generation_config=generation_config)
|
||||
distractors_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0][len(prompt):].strip()
|
||||
distractors = [d.strip() for d in distractors_text.split(",") if d.strip()]
|
||||
|
||||
return ", ".join(distractors[:3])
|
||||
|
||||
# Example usage
|
||||
context = "In physics, the concept of jerk is used to describe the rate of change of acceleration."
|
||||
question = "What is the physical quantity that jerk is the rate of change of?"
|
||||
answer = "Acceleration"
|
||||
instruction = "Generate plausible but incorrect answer choices."
|
||||
|
||||
distractors = generate_distractors(context, question, answer, instruction, model, tokenizer)
|
||||
print("Distractors:", distractors)
|
||||
|
||||
|
||||
# Output: velocity, momentum, force
|
||||
```
|
||||
|
||||
## Dataset Used for Training
|
||||
[More Information Needed]
|
||||
|
||||
## Training Details
|
||||
- **Hardware Used**: T4 GPU (Google Colab)
|
||||
- **Fine-tuned from**: LLaMA 3.2 1B
|
||||
- **Training Framework**: `transformers` + `SFTTrainer`
|
||||
|
||||
## Evaluation Metrics
|
||||
The model was evaluated using BLEU and ROUGE scores to compare generated distractors with reference distractors.
|
||||
|
||||
## Citation
|
||||
If you use this model, please cite:
|
||||
```
|
||||
@article{llama3.2_distractor_gen,
|
||||
title={Distractor Generation using LLaMA 3.2},
|
||||
author={Birendra Sharma},
|
||||
year={2025},
|
||||
publisher={Hugging Face Model Hub}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
For more details, visit the [Hugging Face model page](https://huggingface.co/BirendraSharma/llama3.2_1B_distractors_generation).
|
||||
|
||||
42
config.json
Normal file
42
config.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"_name_or_path": "/content/drive/MyDrive/llama/gguf",
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 128000,
|
||||
"eos_token_id": [
|
||||
128001,
|
||||
128008,
|
||||
128009
|
||||
],
|
||||
"head_dim": 64,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 2048,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 8192,
|
||||
"max_position_embeddings": 131072,
|
||||
"mlp_bias": false,
|
||||
"model_type": "llama",
|
||||
"num_attention_heads": 32,
|
||||
"num_hidden_layers": 16,
|
||||
"num_key_value_heads": 8,
|
||||
"pad_token_id": 128004,
|
||||
"pretraining_tp": 1,
|
||||
"rms_norm_eps": 1e-05,
|
||||
"rope_scaling": {
|
||||
"factor": 32.0,
|
||||
"high_freq_factor": 4.0,
|
||||
"low_freq_factor": 1.0,
|
||||
"original_max_position_embeddings": 8192,
|
||||
"rope_type": "llama3"
|
||||
},
|
||||
"rope_theta": 500000.0,
|
||||
"tie_word_embeddings": true,
|
||||
"torch_dtype": "float16",
|
||||
"transformers_version": "4.48.2",
|
||||
"unsloth_version": "2024.11.7",
|
||||
"use_cache": true,
|
||||
"vocab_size": 128256
|
||||
}
|
||||
14
generation_config.json
Normal file
14
generation_config.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"bos_token_id": 128000,
|
||||
"do_sample": true,
|
||||
"eos_token_id": [
|
||||
128001,
|
||||
128008,
|
||||
128009
|
||||
],
|
||||
"max_length": 131072,
|
||||
"pad_token_id": 128004,
|
||||
"temperature": 0.6,
|
||||
"top_p": 0.9,
|
||||
"transformers_version": "4.48.2"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0de12cfac5b32098cd2821d60aeb24096b8e20faedc11831a1497d6e1aeb6add
|
||||
size 2471645464
|
||||
23
special_tokens_map.json
Normal file
23
special_tokens_map.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"bos_token": {
|
||||
"content": "<|begin_of_text|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "<|eot_id|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|finetune_right_pad_id|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e7dc5d14501e773afcda94d94550fb03b391ab6168eb1a10bd08bfbd8d9661a7
|
||||
size 17210198
|
||||
2065
tokenizer_config.json
Normal file
2065
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user