Update README.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285---license: mitdatasets:- tuandunghcmut/normal_datasetlanguage:- enmetrics:- accuracy- perplexitybase_model:- unsloth/Qwen2.5-Coder-1.5B-Instructpipeline_tag: text-generation---# Using Unsloth to Load and Run Qwen25_Coder_MultipleChoiceUnsloth offers significant inference speed improvements for the Qwen25_Coder_MultipleChoice model. Here's how to properly load and use the model with Unsloth:## InstallationFirst, install the required packages:```bashpip install unsloth transformers torch accelerate# Flash-attention is REQUIRED for correct model behavior!pip install flash-attn --no-build-isolation```## Loading the Model with Unsloth```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torchfrom unsloth import FastLanguageModelimport os# Optional: Set HuggingFace Hub token if you have onehf_token = os.environ.get("HF_TOKEN") # or directly provide your token# Verify flash-attention installation - REQUIRED for correct resultstry:import flash_attnexcept ImportError:raise ImportError("flash-attn package is required for correct model behavior.\n""Please install it with: pip install flash-attn --no-build-isolation")# Model ID on HuggingFace Hubmodel_id = "tuandunghcmut/Qwen25_Coder_MultipleChoice"print(f"Loading model from HuggingFace Hub: {model_id}")# First load tokenizertokenizer = AutoTokenizer.from_pretrained(model_id,token=hf_token,trust_remote_code=True)model, tokenizer = FastLanguageModel.from_pretrained(model_name=model_id,token=hf_token,max_seq_length=2048, # Adjust based on your memory constraintsdtype=None, # Auto-detect best dtypeload_in_4bit=True, # Use 4-bit quantization for efficiency)# Enable fast inference modeFastLanguageModel.for_inference(model)print("Successfully loaded model with Unsloth and flash-attention!")```> ⚠️ **WARNING**: Using this model without flash-attention will produce incorrect results. The flash-attention package is not just for speed, but essential for proper model functionality.Alternatively, you can load the model with transformers first and then apply Unsloth optimization:```python# Alternative approach (Method 2)# First load with transformersmodel = AutoModelForCausalLM.from_pretrained(model_id,token=hf_token,torch_dtype=torch.bfloat16,device_map="auto",trust_remote_code=True)# Then apply Unsloth optimization with flash-attentionFastLanguageModel.for_inference(model, use_flash_attention=True)```## Running Multiple-Choice InferenceAfter loading the model with Unsloth, use it to answer multiple-choice questions:```pythondef format_prompt(question, choices):# Format choices as a lettered listformatted_choices = "\n".join([f"{chr(65 + i)}. {choice}" for i, choice in enumerate(choices)])return f"""QUESTION:{question}CHOICES:{formatted_choices}Analyze this question step-by-step and provide a detailed explanation.Your response MUST be in YAML format as follows:understanding: |<your understanding of what the question is asking>analysis: |<your analysis of each option>reasoning: |<your step-by-step reasoning process>conclusion: |<your final conclusion>answer: <single letter A through {chr(64 + len(choices))}>The answer field MUST contain ONLY a single character letter."""def get_answer(question, choices, model, tokenizer):# Create the promptprompt = format_prompt(question, choices)# Format as chat for the modelmessages = [{"role": "user", "content": prompt}]chat_text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True)# Tokenize and generateinputs = tokenizer(chat_text, return_tensors="pt").to(model.device)# Generate with Unsloth-optimized modeloutput = model.generate(inputs.input_ids,max_new_tokens=512,temperature=0.0, # Use deterministic generation for multiple choicedo_sample=False)# Extract and return responseresponse = tokenizer.decode(output[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)# Extract answer using regeximport reanswer_match = re.search(r'answer:\s*([A-Z])', response)if answer_match:answer = answer_match.group(1)else:# Default fallback if no answer foundanswer = "A"return {"answer": answer,"full_response": response}# Example usagejava_example = {"question": "Which of the following correctly creates a new instance of a class in Java?","choices": ["MyClass obj = new MyClass();","var obj = MyClass();","MyClass obj = MyClass.new();","obj = new(MyClass);"],"answer": "A" # Optional ground truth}result = get_answer(java_example["question"],java_example["choices"],model,tokenizer)print(f"Answer: {result['answer']}")print(f"Full explanation:\n{result['full_response']}")```## Processing Multiple Questions in BatchFor better efficiency with multiple questions, use batch processing:```pythondef batch_process_questions(questions_list, model, tokenizer, batch_size=4):"""Process multiple questions in efficient batches"""results = []for i in range(0, len(questions_list), batch_size):batch = questions_list[i:i+batch_size]batch_prompts = []# Prepare all prompts in the batchfor item in batch:prompt = format_prompt(item["question"], item["choices"])messages = [{"role": "user", "content": prompt}]chat_text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True)batch_prompts.append(chat_text)# Tokenize all inputs with paddingtokenizer.padding_side = "left" # Important for causal LM generationinputs = tokenizer(batch_prompts,return_tensors="pt",padding=True).to(model.device)# Generate all outputsoutputs = model.generate(inputs.input_ids,attention_mask=inputs.attention_mask,max_new_tokens=2048,temperature=0.0,do_sample=False,pad_token_id=tokenizer.pad_token_id)# Process each responsefor j, output_ids in enumerate(outputs):# Calculate where the generated text beginsinput_length = inputs.input_ids[j].ne(tokenizer.pad_token_id).sum().item()# Decode only the generated partresponse = tokenizer.decode(output_ids[input_length:],skip_special_tokens=True)# Extract answerimport reanswer_match = re.search(r'answer:\s*([A-Z])', response)answer = answer_match.group(1) if answer_match else "A"# Store resultresults.append({"question": batch[j]["question"],"answer": answer,"full_response": response})return results```## Performance Tips for Unsloth1. **Flash Attention REQUIRED**: Flash Attention is not just a performance option but a requirement for this model to function correctly:```bashpip install flash-attn --no-build-isolation```2. **Memory Optimization**: If you encounter memory issues, reduce `max_seq_length` or use 4-bit quantization:```pythonmodel, tokenizer = FastLanguageModel.from_pretrained(model_name=model_id,max_seq_length=1024, # Reduced from 2048load_in_4bit=True,use_flash_attention=True # Always enable)```3. **Batch Processing**: For multiple questions, always use batching as it's significantly faster.4. **Prefill Optimization**: Unsloth has special optimizations for prefill that work best with long contexts and batch processing.5. **GPU Selection**: If you have multiple GPUs, you can specify which to use:```pythonos.environ["CUDA_VISIBLE_DEVICES"] = "0" # Use first GPU```<!-- With these optimizations, Qwen25_Coder_MultipleChoice will run correctly while maintaining the high-quality multiple-choice reasoning and answers. -->```123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619# Using tuandunghcmut/Qwen25_Coder_MultipleChoiceThis document provides everything you need to get started with the `tuandunghcmut/Qwen25_Coder_MultipleChoice` model for multiple-choice coding questions.## Installation and Setup### PrerequisitesMake sure you have Python 3.8+ installed. Then install the required packages:```bash# Install core dependenciespip install transformers torch pandas# For faster inference (important)pip install unsloth accelerate bitsandbytes# Flash Attention (highly recommended for speed)pip install flash-attn --no-build-isolation# For dataset handling and YAML parsingpip install datasets pyyaml```### Flash Attention SetupFlash Attention provides a significant speedup for transformer models. To use it with the Qwen model:1. Install Flash Attention as shown above2. Enable it when loading the model:```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizer# Enable Flash Attention during model loadingmodel = AutoModelForCausalLM.from_pretrained("tuandunghcmut/Qwen25_Coder_MultipleChoice",torch_dtype=torch.bfloat16,device_map="auto",trust_remote_code=True,use_flash_attention_2=True # Enable Flash Attention)```Flash Attention will provide:- 2-3x faster inference speed- Lower memory usage- Compatible with 4-bit quantization for even more efficiency### Environment VariablesIf you're using Hugging Face Hub models, you may want to set up your access token:```bash# Set environment variable for Hugging Face tokenexport HF_TOKEN="your_huggingface_token_here"# Or in Pythonimport osos.environ["HF_TOKEN"] = "your_huggingface_token_here"```### GPU SetupFor optimal performance, you'll need a CUDA-compatible GPU. Check your installation:```bash# Verify CUDA is availablepython -c "import torch; print('CUDA available:', torch.cuda.is_available())"# Print CUDA device infopython -c "import torch; print('CUDA device count:', torch.cuda.device_count()); print('CUDA device name:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'No GPU')"```## Required ClassesBelow are the essential classes needed to work with the model. Copy these into your Python files to use them in your project.### PromptCreatorThis class formats prompts for multiple-choice questions:```pythonclass PromptCreator:"""Creates and formats prompts for multiple choice questionsSupports different prompt styles for training and inference"""# Prompt typesBASIC = "basic" # Simple answer-only formatYAML_REASONING = "yaml" # YAML formatted reasoningTEACHER_REASONED = "teacher" # Same YAML format as YAML_REASONING but using teacher completions for trainingdef __init__(self, prompt_type=BASIC):self.prompt_type = prompt_type# Initialize parser mode based on prompt typeif prompt_type == self.YAML_REASONING or prompt_type == self.TEACHER_REASONED:self.parser_mode = "yaml"else:self.parser_mode = "basic"def format_choices(self, choices):"""Format choices with letter prefixes"""return "\n".join([f"{chr(65 + i)}. {choice}" for i, choice in enumerate(choices)])def get_max_letter(self, choices):"""Get the last valid letter based on choice count"""return chr(65 + len(choices) - 1)def create_inference_prompt(self, question, choices):"""Create a prompt for inference based on the configured prompt type"""formatted_choices = self.format_choices(choices)max_letter = self.get_max_letter(choices)if self.prompt_type == self.BASIC:return self._create_basic_prompt(question, formatted_choices, max_letter)elif self.prompt_type == self.YAML_REASONING or self.prompt_type == self.TEACHER_REASONED:return self._create_yaml_prompt(question, formatted_choices, max_letter)else:return self._create_basic_prompt(question, formatted_choices, max_letter)def _create_basic_prompt(self, question, formatted_choices, max_letter):"""Create a basic prompt that just asks for an answer letter"""return f"""{question}{formatted_choices}Select the correct answer from A through {max_letter}:"""def _create_yaml_prompt(self, question, formatted_choices, max_letter):"""Create a prompt with YAML formatted reasoning structure"""return f"""{question}{formatted_choices}Think through this step-by-step:- Understand what the question is asking- Analyze each option carefully- Reason about why each option might be correct or incorrect- Select the most appropriate answerYour response should be in YAML format:understanding: |<your understanding of the question>analysis: |<your analysis of each option>reasoning: |<your reasoning about the correct answer>conclusion: |<your final conclusion>answer: <single letter A through {max_letter} representing your final answer>"""def create_training_prompt(self, question, choices):"""Create a prompt for training based on the configured prompt type"""formatted_choices = self.format_choices(choices)max_letter = self.get_max_letter(choices)if self.prompt_type == self.BASIC:return self._create_basic_training_prompt(question, formatted_choices, max_letter)elif self.prompt_type == self.YAML_REASONING or self.prompt_type == self.TEACHER_REASONED:return self._create_yaml_training_prompt(question, formatted_choices, max_letter)else:return self._create_basic_training_prompt(question, formatted_choices, max_letter)def _create_basic_training_prompt(self, question, formatted_choices, max_letter):"""Create a basic training prompt"""return f"""{question}{formatted_choices}Select the correct answer from A through {max_letter}:"""def _create_yaml_training_prompt(self, question, formatted_choices, max_letter):"""Create a training prompt with YAML formatted reasoning structure"""return f"""{question}{formatted_choices}Think through this step-by-step:- Understand what the question is asking- Analyze each option carefully- Reason about why each option might be correct or incorrect- Select the most appropriate answerYour response should be in YAML format:understanding: |<your understanding of the question>analysis: |<your analysis of each option>reasoning: |<your reasoning about the correct answer>conclusion: |<your final conclusion>answer: <single letter A through {max_letter} representing your final answer>"""def set_prompt_type(self, prompt_type):"""Set the prompt type and update parser mode accordingly"""self.prompt_type = prompt_typeif prompt_type == self.YAML_REASONING or prompt_type == self.TEACHER_REASONED:self.parser_mode = "yaml"else:self.parser_mode = "basic"def is_teacher_mode(self):"""Check if prompt type is teacher mode"""return self.prompt_type == self.TEACHER_REASONED```### ResponseParserThis class extracts answers from model responses:```pythonclass ResponseParser:"""Parser for model responses with support for different formatsExtracts answers and reasoning from model outputs"""# Parser modesBASIC = "basic" # Extract single letter answerYAML = "yaml" # Parse YAML formatted response with reasoningdef __init__(self, parser_mode=BASIC):"""Initialize with parser mode (basic or yaml)"""self.parser_mode = parser_modedef parse(self, response_text):"""Parse the response text and extract answer and reasoning"""if self.parser_mode == self.YAML:return self._parse_yaml_response(response_text)else:return self._parse_basic_response(response_text)def _parse_basic_response(self, response_text):"""Parse a basic response to extract the answer letterReturns:tuple: (answer_letter, None)"""# Look for just the letter at the end of textimport re# Try to find the last occurrence of letters A-Z by themselvesmatches = re.findall(r'\b([A-Z])\b', response_text)if matches:return matches[-1], None # Return the last matching letter# Try to find "The answer is X" patternanswer_match = re.search(r'[Tt]he answer is[:\s]+([A-Z])', response_text)if answer_match:return answer_match.group(1), None# If nothing else works, just get the last uppercase letteruppercase_letters = re.findall(r'[A-Z]', response_text)if uppercase_letters:return uppercase_letters[-1], Nonereturn None, None # No answer founddef _parse_yaml_response(self, response_text):"""Parse a YAML formatted response to extract the answer and reasoningReturns:tuple: (answer_letter, reasoning_dict)"""import reimport yaml# First try to extract just the answer fieldanswer_match = re.search(r'answer:\s*([A-Z])', response_text)answer = answer_match.group(1) if answer_match else None# Try to extract the entire YAMLtry:# Remove potential code block markersyaml_text = response_textif "```yaml" in yaml_text:yaml_text = yaml_text.split("```yaml")[1]if "```" in yaml_text:yaml_text = yaml_text.split("```")[0]elif "```" in yaml_text:# Assume the whole thing is a code blockparts = yaml_text.split("```")if len(parts) >= 3:yaml_text = parts[1]# Parse the YAMLparsed_yaml = yaml.safe_load(yaml_text)# If successful, use the answer from the YAML, and return the parsed structureif isinstance(parsed_yaml, dict) and "answer" in parsed_yaml:return parsed_yaml.get("answer"), parsed_yamlexcept Exception:# If YAML parsing fails, we already have the answer from regexpassreturn answer, Nonedef set_parser_mode(self, parser_mode):"""Set the parser mode"""self.parser_mode = parser_mode@classmethoddef from_prompt_type(cls, prompt_type):"""Create a ResponseParser with the appropriate mode based on prompt typeArgs:prompt_type: The prompt type (e.g., PromptCreator.YAML_REASONING)Returns:ResponseParser: A parser configured for the prompt type"""if prompt_type in ["yaml", "teacher"]:return cls("yaml")else:return cls("basic")```### QwenModelHandlerThis class handles model loading and inference:```pythonclass QwenModelHandler:def __init__(self, model_name="unsloth/Qwen2.5-7B", max_seq_length=768,quantization=None, device_map="auto", cache_dir=None,use_flash_attention=True):"""Initialize a handler for Qwen modelsArgs:model_name: Model identifier (local path or Hugging Face model ID)max_seq_length: Maximum sequence lengthquantization: Quantization method ("4bit", "8bit", or None)device_map: Device mapping strategycache_dir: Directory to cache downloaded modelsuse_flash_attention: Whether to use Flash Attention 2 for faster inference"""self.model_name = model_nameself.max_seq_length = max_seq_lengthself.quantization = quantizationself.device_map = device_mapself.cache_dir = cache_dirself.use_flash_attention = use_flash_attentionself.model = Noneself.tokenizer = None# Load the model and tokenizerself._load_model()def _load_model(self):"""Load the model and tokenizer with appropriate settings"""from transformers import AutoModelForCausalLM, AutoTokenizerimport torch# Load tokenizerself.tokenizer = AutoTokenizer.from_pretrained(self.model_name,trust_remote_code=True,cache_dir=self.cache_dir)# Prepare model loading kwargsmodel_kwargs = {"trust_remote_code": True,"cache_dir": self.cache_dir,"device_map": self.device_map,}# Add Flash Attention if requested and availableif self.use_flash_attention:try:import flash_attnmodel_kwargs["use_flash_attention_2"] = Trueprint("Flash Attention 2 enabled!")except ImportError:print("Flash Attention not available. For faster inference, install with: pip install flash-attn")# Add quantization if specifiedif self.quantization == "4bit":try:from transformers import BitsAndBytesConfigmodel_kwargs["quantization_config"] = BitsAndBytesConfig(load_in_4bit=True,bnb_4bit_compute_dtype=torch.bfloat16)except ImportError:print("bitsandbytes not available, loading without 4-bit quantization")elif self.quantization == "8bit":model_kwargs["load_in_8bit"] = Trueelse:model_kwargs["torch_dtype"] = torch.bfloat16# Load the modelself.model = AutoModelForCausalLM.from_pretrained(self.model_name,**model_kwargs)def generate_with_streaming(self, prompt, temperature=0.7, max_tokens=1024, stream=True):"""Generate text from the model with optional streamingArgs:prompt: Input text prompttemperature: Temperature for sampling (0 for deterministic)max_tokens: Maximum number of tokens to generatestream: Whether to stream the outputReturns:String containing the generated text, or generator if streaming"""import torch# Tokenize promptinputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device)input_ids = inputs.input_idsattention_mask = inputs.attention_mask# Set generation parametersgeneration_config = {"max_new_tokens": max_tokens,"temperature": temperature,"do_sample": temperature > 0,"top_p": 0.95 if temperature > 0 else 1.0,"repetition_penalty": 1.1,"pad_token_id": self.tokenizer.eos_token_id,}# If not streaming, do normal generationif not stream:with torch.no_grad():outputs = self.model.generate(input_ids=input_ids,attention_mask=attention_mask,**generation_config)# Decode the generated text (skip the prompt)generated_text = self.tokenizer.decode(outputs[0][input_ids.shape[1]:],skip_special_tokens=True)return generated_text# If streaming, yield generated tokens one by oneelse:generated = []# Initialize generatorwith torch.no_grad():generated_ids = self.model.generate(input_ids=input_ids,attention_mask=attention_mask,**generation_config,streamer=None # Would need a custom streamer here if available)# Decode the entire sequence at once (not truly streaming, but simpler)full_text = self.tokenizer.decode(generated_ids[0][input_ids.shape[1]:],skip_special_tokens=True)return full_text```## Hardware Requirements and Optimization### Flash Attention BenefitsFlash Attention is a highly optimized implementation of the attention mechanism that:1. **Speeds up inference by 2-3x** compared to standard attention2. **Reduces memory usage** by avoiding materializing large attention matrices3. **Works perfectly with 4-bit quantization** for even further optimization4. **Scales better with sequence length**, which is important for complex coding questionsFor the best performance, make sure to:- Install Flash Attention (`pip install flash-attn`)- Enable it when loading the model (see QwenModelHandler class)- Use with CUDA-compatible NVIDIA GPUs### Hardware RecommendationsFor optimal performance, we recommend:- **GPU**: NVIDIA GPU with at least 8GB VRAM (16GB+ recommended for larger models)- **RAM**: 16GB+ system RAM- **Storage**: At least 10GB free disk space for model files- **CPU**: Modern multi-core processor (for preprocessing)### Reducing Memory UsageIf you're facing memory constraints:```python# Use 4-bit quantization with Flash Attention for optimal memory-efficiencymodel_handler = QwenModelHandler(model_name="tuandunghcmut/Qwen25_Coder_MultipleChoice",quantization="4bit",use_flash_attention=True)# Further optimize with unslothtry:from unsloth.models import FastLanguageModelFastLanguageModel.for_inference(model_handler.model)print("Using unsloth for additional optimization")except ImportError:print("unsloth not available")```## Usage ExampleHere's how to use these classes with Flash Attention enabled:```python# 1. Load the model with Flash Attention and 4-bit quantizationfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torchhub_model_id = "tuandunghcmut/Qwen25_Coder_MultipleChoice"# Create model handler with Flash Attention and 4-bit quantizationmodel_handler = QwenModelHandler(model_name=hub_model_id,max_seq_length=2048,quantization="4bit",use_flash_attention=True)# Optional: Use unsloth for even faster inferencetry:from unsloth.models import FastLanguageModelFastLanguageModel.for_inference(model_handler.model)print("Using unsloth for faster inference")except ImportError:print("unsloth not available, using standard inference")# 2. Create prompt creator with YAML reasoning formatprompt_creator = PromptCreator(PromptCreator.YAML_REASONING)# 3. Example questionquestion = "Which of the following correctly defines a list comprehension in Python?"choices = ["[x**2 for x in range(10)]","for(x in range(10)) { return x**2; }","map(lambda x: x**2, range(10))","[for x in range(10): x**2]"]# 4. Create prompt and generate answerprompt = prompt_creator.create_inference_prompt(question, choices)response = model_handler.generate_with_streaming(prompt, temperature=0.0, stream=False)# 5. Parse the responseparser = ResponseParser(prompt_creator.parser_mode)answer, reasoning = parser.parse(response)print(f"Question: {question}")print(f"Answer: {answer}")if reasoning:print(f"Reasoning: {reasoning}")```## Troubleshooting### Common Issues1. **Flash Attention Installation Issues**: If you encounter problems installing `flash-attn`:```bash# Try with specific CUDA version (e.g., for CUDA 11.8)pip install flash-attn==2.3.4+cu118 --no-build-isolation# For older GPUspip install flash-attn==2.3.4 --no-build-isolation```2. **CUDA Out of Memory**: Try combining 4-bit quantization with Flash Attention.```pythonmodel_handler = QwenModelHandler(model_name=hub_model_id,quantization="4bit",use_flash_attention=True)```3. **Module Not Found Errors**: Make sure you've installed all required packages.```bashpip install transformers torch unsloth datasets pyyaml bitsandbytes flash-attn```4. **Parsing Errors**: If the model isn't producing valid YAML responses, try adjusting the temperature:```pythonresponse = model_handler.generate_with_streaming(prompt, temperature=0.0, stream=False)```### Getting HelpIf you encounter issues, check the [model repository on Hugging Face](https://huggingface.co/tuandunghcmut/Qwen25_Coder_MultipleChoice) for updates and community discussions.This guide provides you with all the necessary code and optimization techniques to use the model effectively for multiple-choice coding questions.
README.md+546-212