from unsloth import FastModelfrom unsloth.chat_templates import get_chat_template model, tokenizer = FastModel.from_pretrained( model_name = "makiisthebes/gemma_4_lora_32b_model_financial", max_seq_length = 8192, load_in_4bit = True,) tokenizer = get_chat_template(tokenizer, chat_template="gemma-4-thinking") article = "Your financial news article text here..." prompt = f"""Please extract the relevant information from the provided news article in JSON format.Provide the output in the following JSON structure: {{ "description": "A brief summary of the news article.", "keywords": ["disclosure", "bankruptcy", "lawsuit"], "insights": [ {{ "ticker": "AAPL", "sentiment": "positive||negative||neutral", "sentiment_reasoning": "A detailed explanation of the sentiment analysis for the given ticker." }} ]}} These details should be extracted based on the content of the news article provided below.Please ensure that the output is in valid JSON format and adheres to the specified structure.Do not include anything other than pure JSON in your response, including ```json or any explanatory text.News Article: {article}""" messages = [{"role": "user", "content": [{"type": "text", "text": prompt}]}] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, return_tensors="pt", tokenize=True, return_dict=True,).to("cuda") outputs = model.generate( **inputs, max_new_tokens=512, use_cache=True, temperature=1.0, top_p=0.95, top_k=64, # Gemma-4 recommended settings) print(tokenizer.decode(outputs[0], skip_special_tokens=True))