This model is a fine-tuned version of Microsoft's Phi-4-mini-instruct (3.8B parameters), specialized for blockchain market analysis with explicit reasoning capabilities. It's designed to analyze on-chain data, identify patterns and anomalies, and provide actionable insights with transparent reasoning processes.
Break down complex market data into structured components
Perform numerical calculations and identify correlations
Recognize patterns across multiple metrics
Separate detailed reasoning (using <thinking> tags) from concise summaries
Provide actionable insights with specific price targets
This model is part of the NEAR Cortex-1 initiative, which aims to create AI models that can analyze blockchain data with transparent reasoning processes.
Usage
The model is designed to analyze blockchain market data and provide both detailed reasoning and concise conclusions. It uses <thinking> tags to separate its reasoning process from its final analysis.
python
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
34# Load model and tokenizer5model_name ="Jarrodbarnes/cortex-1-mini"6tokenizer = AutoTokenizer.from_pretrained(model_name)7model = AutoModelForCausalLM.from_pretrained(8 model_name,9 torch_dtype=torch.float16,10 device_map="auto"11)1213# Example prompt14prompt ="""Please analyze this market data and show your reasoning:
1516Given the following Ethereum market data:
17- Daily Transactions: 1.5M (up 8% from average)
18- Current Price: $3,450
19- Exchange Outflows: 52K ETH (up 20%)"""2021# Generate response22inputs = tokenizer(prompt, return_tensors="pt").to(model.device)23outputs = model.generate(24 inputs["input_ids"],25 max_new_tokens=512,26 temperature=0.7,27 do_sample=True28)2930# Print response31response = tokenizer.decode(outputs[0], skip_special_tokens=True)32print(response)
Post-Processing for Thinking Tags
The model sometimes has issues with the proper formatting of <thinking> tags. We recommend implementing the following post-processing function:
python
1defclean_thinking_tags(text, prompt):2"""
3 Clean up thinking tags in the response.
45 Args:
6 text: Raw model response
7 prompt: Original prompt
89 Returns:
10 Cleaned response with proper thinking tags
11 """12# Extract content after the prompt13if prompt in text:14 text = text[len(prompt):].strip()1516# Handle case where model repeats <thinking> tags17 thinking_tag_count = text.count("<thinking>")18if thinking_tag_count >1:19# Keep only the first <thinking> tag20 first_tag_pos = text.find("<thinking>")21 text_after_first_tag = text[first_tag_pos:]2223# Replace subsequent <thinking> tags with newlines24 modified_text = text_after_first_tag
25for i inrange(thinking_tag_count -1):26 modified_text = modified_text.replace("<thinking>","\n",1)2728 text = text[:first_tag_pos]+ modified_text
2930# Ensure there's a </thinking> tag if there's a <thinking> tag31if"<thinking>"in text and"</thinking>"notin text:32# Add </thinking> before what looks like a conclusion33 conclusion_markers =["In conclusion","To summarize","Overall",34"Final analysis","Therefore","Based on this analysis"]35for marker in conclusion_markers:36if marker in text:37 parts = text.split(marker,1)38 text = parts[0]+"</thinking>\n\n"+ marker + parts[1]39break40else:41# If no conclusion marker, add </thinking> at 80% of the text42 split_point =int(len(text)*0.8)43 text = text[:split_point]+"\n</thinking>\n\n"+ text[split_point:]4445return text
Training Details
Base Model: microsoft/Phi-4-mini-instruct (3.8B parameters)
Training Method: LoRA fine-tuning (r=16, alpha=16)