Views
No views yet
meta-llama/Llama-3.2-3B-Instruct, specifically trained to evaluate investment offers and make optimal deal decisions in simulated Shark Tank scenarios. It processes company details (background, financials, sales, initial ask) and investor offers, then generates a reasoned decision, including accepting a specific deal with terms or declining all offers, following a structured format.trl library. GRPO optimizes the model's policy based on rewards calculated from multiple generated outputs, guided by custom reward functions designed to enforce specific structural, formatting, and content requirements. The Unsloth library was used for efficient loading and inference.1# !pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
2# !pip install --no-deps trl peft accelerate bitsandbytes
3
4from unsloth import FastLanguageModel
5import torch
6from transformers import TextStreamer
7
8max_seq_length = 3000 # Choose any! We auto support RoPE Scaling internally!
9dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
10load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
11
12# IMPORTANT: Replace with your actual model ID
13model_id = "VaidikML0508/Shark-Tank-Offer-Evaluator-llama3.2-3B-Instruct-SFT-DPO-4bits-V1"
14
15model, tokenizer = FastLanguageModel.from_pretrained(
16 model_name = model_id,
17 max_seq_length = max_seq_length,
18 dtype = dtype,
19 load_in_4bit = load_in_4bit,
20)
21FastLanguageModel.for_inference(model) # Enable native 2x faster inference
22
23# Define the system prompt and input template
24# (Using the chat template structure implied by the user's generation code)
25SYS_PROMPT = """You are the founder of a company, pitching your business on *Shark Tank* to secure the best possible deal from the sharks. Your goal is to make the best decision for your company by evaluating shark offers, negotiating effectively, and choosing the most beneficial deal—or deciding to walk away if necessary.
26
27You must structure your response within `<reasoning>` tags explaining your thought process, followed by `<answer>` tags containing the final decision.
28
29### **Final Decision Format within `<answer>`:**
30Once all sharks have made their offers, analyze them and decide.
31
32#### **Accepted Offer:**
33If a deal is accepted, the response *must* include the investment amount, the equity offered, and any special conditions, structured using these exact special tokens:
34`<|accepted_offer|> <|money|> [AMOUNT] <|end_money|> for <|equity|> [PERCENTAGE] <|end_equity|> % <|shark_pitch|> [SHARK'S PITCH SUMMARY] <|what_makes_shark_to_offer|> [REASON SHARK OFFERED] <|condition|> [ANY CONDITIONS, optional] <|endoftext|>`
35
36##### **Example:**
37`<answer><|accepted_offer|> <|money|> 150000 <|end_money|> for <|equity|> 17.5 <|end_equity|> % <|shark_pitch|> Blake offered his expertise and resources... <|what_makes_shark_to_offer|> Blake was impressed by Carson's knowledge... <|condition|> Contingent on securing a line of credit. <|endoftext|></answer>`
38
39#### **No Deal:**
40If no deal is made, the response *must* explain the reasoning within `<reasoning>` and the `<answer>` block must *only* contain:
41`<|accepted_offer|> <|No_Deal|> <|endoftext|>`
42
43##### **Example:**
44`<answer><|accepted_offer|> <|No_Deal|> <|endoftext|></answer>`
45"""
46
47# Format data of company like below.
48company_input_data = """<|company_name|> GreenGrow Planters <|endoftext|>
49<|company_background|> GreenGrow Planters is an eco-friendly gardening solution that transforms household food waste into nutrient-rich compost. Their patented self-watering planter system uses a special filtration method that accelerates the composting process while eliminating odors. The company has also developed companion products including GreenGrow Sprouts for seedlings and GreenGrow XL for larger plants, all using their proprietary biodegradable materials. <|endoftext|>
50<|sales_details|> The company has generated $340,000 in sales over the past three years, with $180,000 in the last year alone. They project $500,000 in sales for the coming year. Currently, 85% of sales come from their e-commerce platform and 15% from specialty garden stores. The product is available in 1,200 retail locations through partnerships with sustainable living retailers. <|endoftext|>
51<|financials|> The standard GreenGrow Planter costs $4.75 to manufacture and ships for $8.50 wholesale, retailing for $19.99. The GreenGrow Sprouts starter kit costs $2.25 to manufacture, wholesales for $5.99, and retails for $12.99. The GreenGrow XL costs $7.50 to manufacture, wholesales for $14.99, and retails for $29.99. <|endoftext|>
52<|initial_ask|> <|money|> 250000 <|end_money|> for <|equity|> 15 <|end_equity|> % <|endoftext|>
53
54Shark Offers:
55<|shark_offer|> <|money|> 300000 <|end_money|> for <|equity|> 30 <|end_equity|> % <|shark_pitch|> Lori offered her QVC connections and retail expertise to scale the business quickly, promising to make GreenGrow a household name within a year. <|what_makes_shark_to_offer|> Lori loved the sustainability angle and believed the product would resonate strongly with her customer base. <|endoftext|>
56<|shark_offer|> <|money|> 250000 <|end_money|> for <|equity|> 20 <|end_equity|> % <|shark_pitch|> Mark proposed a strategic partnership focusing on improving the technology and expanding the product line with smart garden features. <|what_makes_shark_to_offer|> Mark was impressed by the innovation and saw potential to integrate IoT technology into future versions. <|endoftext|>
57<|shark_offer|> <|money|> 200000 <|end_money|> for <|equity|> 15 <|end_equity|> % plus $2 royalty until $400,000 is recouped <|shark_pitch|> Kevin offered less equity but added a royalty structure to protect his investment while allowing the founders to maintain more control. <|what_makes_shark_to_offer|> Kevin appreciated the solid margins and wanted to structure a deal that would ensure quick returns while incentivizing growth. <|endoftext|>
58<|shark_offer|> <|money|> 250000 <|end_money|> for <|equity|> 25 <|end_equity|> % <|shark_pitch|> Robert offered to leverage his connections in the home improvement sector to get the product into major retailers nationwide. <|what_makes_shark_to_offer|> Robert connected with the founders' passion and saw a clear path to scaling through his existing retail relationships. <|endoftext|>"""
59
60# Apply chat template
61messages = [
62 {'role': 'system', 'content': SYS_PROMPT},
63 {"role" : "user", "content" : f"Details are:\n\n{company_input_data}"},
64]
65text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
66inputs = tokenizer(text, return_tensors="pt").to("cuda")
67
68# Generate response
69streamer = TextStreamer(tokenizer)
70outputs = model.generate(**inputs, streamer=streamer, max_new_tokens=1024, temperature=0.1, top_p=0.95, pad_token_id=tokenizer.eos_token_id)
71
72# # To get the full output string without streaming:
73# outputs = model.generate(**inputs, max_new_tokens=1024, temperature=0.1, top_p=0.95, pad_token_id=tokenizer.eos_token_id)
74# decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=False) # Keep special tokens to see structure
75# print(decoded_output.split("<|assistant|>")[1]) # Extract assistant's response1<reasoning>
2I have thoroughly evaluated all the offers from the sharks, considering their implications for GreenGrow Planters' future, financial health, and strategic goals. Lori's offer of $300,000 for 30% equity seems aggressive, given our current valuation of $250,000. While her QVC connections and retail expertise could help scale the business quickly, I'm concerned that she may be overpaying for our equity. Mark's proposal for a strategic partnership focusing on improving technology and expanding the product line with smart garden features is intriguing, but his offer of $250,000 for 20% equity seems more reasonable. Kevin's offer of $200,000 for 15% equity plus a royalty structure until $400,000 is recouped is more in line with our valuation, and his focus on quick returns and incentivizing growth aligns with our goals. Robert's offer of $250,000 for 25% equity is also reasonable, but his reliance on his existing retail relationships may not be as effective in expanding our reach as Lori's QVC connections. I must weigh the pros and cons of each offer carefully to make an informed decision.
3</reasoning>
4<answer>
5<|accepted_offer|> <|money|> 200000 <|end_money|> for <|equity|> 15 <|end_equity|> % <|shark_pitch|> Kevin offered less equity but added a royalty structure to protect his investment while allowing the founders to maintain more control. <|what_makes_shark_to_offer|> Kevin appreciated the solid margins and wanted to structure a deal that would ensure quick returns while incentivizing growth. <|condition|> I accept Kevin's offer, as it aligns with our valuation and provides a clear path to scaling the business while maintaining control. <|endoftext|>
6</answer>1<reasoning>
2The offers from the sharks are as follows:
3- Lori offered $300,000 for 30% equity, which is a valuation of $1 million. This is a significant increase from our initial valuation of $1.67 million ($250,000 / 15% equity).
4- Mark offered $250,000 for 20% equity, which is a valuation of $1.25 million. This is also higher than our initial valuation.
5- Kevin offered $200,000 for 15% equity, plus a $2 royalty until $400,000 is recouped. This is a lower valuation, but the royalty structure may provide a steady stream of income.
6- Robert offered $250,000 for 25% equity, which is a valuation of $1 million. This is also higher than our initial valuation.
7
8Considering the offers, Lori and Mark's valuations are higher than our initial valuation, but they also offer more equity. Kevin's offer is lower, but the royalty structure may provide a steady stream of income. Robert's offer is similar to Lori's, but he has existing connections in the home improvement sector.
9
10We need to weigh the pros and cons of each offer. Lori and Mark's valuations are higher, but they also require more equity. Kevin's offer is lower, but the royalty structure may provide a steady stream of income. Robert's offer is similar to Lori's, but he has existing connections in the home improvement sector.
11
12We should consider the potential for growth and the value of the equity we're giving up. We should also consider the potential for the sharks to provide additional resources and expertise to help us grow the business.
13
14Ultimately, we need to decide which offer is the best for our business. We should consider our options carefully and make a decision that aligns with our goals and values.
15
16<answer>
17I will consider all the offers carefully and make a decision based on the pros and cons of each. I will also consider the potential for growth and the value of the equity we're giving up. I will decide whether to accept one of the offers, decline all the offers, or negotiate further.trl library. Unlike DPO which uses pairwise preferences, GRPO optimizes the model by generating multiple candidate responses (num_generations) for a given prompt and evaluating them collectively using a set of reward functions. The gradients are calculated based on these group rewards to update the model's policy, encouraging generations that score highly across the desired metrics (structure, format, content accuracy, reasoning quality).structure_reward_func):<reasoning>...</reasoning><answer>...</answer> structure.<reasoning>, </reasoning>, <answer>, and </answer> tags. It gives a bonus if they appear in the correct sequence (<reasoning> before </reasoning>, which is before <answer>, which is before </answer>). It applies significant penalties if any text appears before <reasoning>, between </reasoning> and <answer>, or after </answer>.answer_format_reward_func):<answer> tags, ensuring it matches either the "Accepted Offer" or "No Deal" template using the specific <|...|> tokens.<answer> perfectly matches the required pattern for an accepted deal (including <|money|>, <|equity|>, <|shark_pitch|>, etc.) or the pattern for a no deal (<|No_Deal|>). If not a perfect match, it grants partial credit for the presence of key required tags like <|accepted_offer|>, <|endoftext|>, <|money|>, <|equity|>, <|No_Deal|>, etc.offer_reward_func):<answer> block matches the ground truth or expected answer.answer_format_reward_func. If the format score is high (e.g., > 0.8), it compares the extracted answer content to the true answer. A perfect match gets a high reward (contributing +1.0). If the format is perfect but the content is wrong, it gets reward only for the format (contributing +0.0 for content). If the format score is low, this reward function gives minimal or zero points for content, focusing only on rewarding based on the partial format score achieved.answer_format_reward_func, plus up to 1.0 for content match if format is good).reasoning_quality_reward_func):<reasoning> tags.<reasoning> tags are present but contain no actual text (empty or just whitespace). It may give a small bonus for using first-person pronouns ("I", "my") to encourage the persona.trl's GRPOConfig with the following key settings:5e-6adamw_torch_fusedcosine with warmup_ratio = 0.10.12 (per device)14 (for group reward calculation)[Value Used, e.g., 2000] (as max_prompt_length)[Value Used, e.g., 1000] (calculated as max_seq_length - max_prompt_length)400500.1wandb32 (specified separately, likely via PEFT config)