Showing posts with label Ollama. Show all posts
Showing posts with label Ollama. Show all posts

Sunday, August 3, 2025

Llama Data Science πŸ¦™πŸ¦™πŸ¦™

πŸ¦™πŸ¦™πŸ¦™ Llama Data ScienceπŸ¦™πŸ¦™πŸ¦™  

Full code and usage at GregariousEngineering/llama-datascience 

In short, ChatGPT’s brand new OPEN-WEIGHTS model gpt-oss does data science better and faster than many people :)

Runner up, Mistral Small 3.2 was also quite competent!


gregarious@hal9000:~/code/llama-datascience$ ./llama_datascience.py --data-file traffic_volume_000256_2004_2024.csv "What is the best time to travel South through the intersection?"
Expert: gpt-oss (temp: 0.5)

--- Expert Reasoning Step 1/20 ---
> Expert wants to use tool: 'python_datascience'
> Reason for tool selection: Load and inspect data
> Code:
import pandas as pd
import numpy as np

# Load data
try:
    df = pd.read_csv('/sandbox/data.csv')
except Exception as e:
    print('Error loading CSV:', e)
    df = None

print('Columns:', df.columns.tolist() if df is not None else None)
print('Head:')
print(df.head() if df is not None else None)

> Code execution complete.
output:
Columns: ['Count Date', 'Dir', '0h', '1h', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', '10h', '11h', '12h', '13h', '14h', '15h', '16h', '17h', '18h', '19h', '20h', '21h', '22h', '23h']
Head:
   Count Date Dir  0h  1h  2h  3h   4h  ...   17h   18h  19h  20h  21h  22h  23h
0  12/01/2024   P  91  45  32  23   21  ...   837   575  445  358  198  149   63
1  12/01/2024   S  49  30  19  28   42  ...   783   535  359  199  164   89   48
2  12/02/2024   P  54  27  20  26   49  ...  1758   794  486  326  237  191  111
3  12/02/2024   S  18  17  15  36  154  ...   924   506  265  214  163  104   54
4  12/03/2024   P  54  27  17  33   52  ...  1745  1017  584  456  331  145  105

[5 rows x 26 columns]


--- Expert Reasoning Step 2/20 ---
> Expert wants to use tool: 'python_datascience'
> Reason for tool selection: Compute average hourly counts for South direction and find best hour
> Code:
import pandas as pd
import numpy as np

# Load data
try:
    df = pd.read_csv('/sandbox/data.csv')
except Exception as e:
    print('Error loading CSV:', e)
    df = None

# Ensure numeric columns
hour_cols = [col for col in df.columns if col.endswith('h')]
# Convert to numeric
for col in hour_cols:
    df[col] = pd.to_numeric(df[col], errors='coerce')

# Filter South direction
south_df = df[df['Dir'] == 'S']

# Compute average per hour across all South rows
avg_counts = south_df[hour_cols].mean()

# Find hour with minimum average
best_hour = avg_counts.idxmin()
print('Average counts per hour for South direction:')
print(avg_counts)
print('\nBest hour (lowest average traffic):', best_hour)

# Also show min count across all South rows for that hour
min_count = south_df[best_hour].min()
print('Minimum count on best hour across all days:', min_count)

> Code execution complete.
output:
Average counts per hour for South direction:
0h       40.570433
1h       25.991288
2h       22.957110
3h       34.281598
4h       97.354108
5h      349.480231
6h      762.930438
7h     1107.911272
8h      900.093553
9h      686.656346
10h     630.000670
11h     644.783273
12h     646.281866
13h     645.476880
14h     654.760488
15h     681.876960
16h     741.068489
17h     734.114194
18h     533.185096
19h     328.717732
20h     260.428897
21h     208.710763
22h     134.479426
23h      70.539204
dtype: float64

Best hour (lowest average traffic): 2h
Minimum count on best hour across all days: 4


--- Expert Reasoning Step 3/20 ---
**Best time to travel South**

The hour with the lowest average vehicle count for the South‑bound direction is **2 h** (the 2 :00 – 3 :00 AM slot).  
Across all days in the data set, the average count for that hour is about **23 vehicles**, and the smallest single‑day count recorded in that hour is **4 vehicles**.

So, if you want the least traffic when heading South through the intersection, aim for the 2 :00 – 3 :00 AM window.

Friday, July 11, 2025

πŸ¦™πŸ¦™πŸ¦™ Llama Panel πŸ¦™πŸ¦™πŸ¦™

A multi-model agentic app to provide internet backed, consensus based answers from a configurable panel of LLMs (ReAct , Self- and Cross-Consistency)

Open Source Greatness in Numbers

Open Source LLMs have come a long way and can now challenge closed source models! Excitingly several Instruction Tuned open source models are now out and proving quite capable. Moreover, thanks to great improvements in efficiency and quantization, capable models are now small enough to run many on one system.

Building on the idea that groups outperform individuals on various cognitive tasks, I set out to create at simple application to see if these latest models perform better as a group!

Python Leading Llama Leading Llamas πŸπŸ¦™πŸ”ŽπŸ¦™πŸ¦™πŸ¦™

For simplicity, I built the app in Python on top of Ollama. A large capable model, ideally instruction tuned, leads the investigation, querying the panel of models and internet until a reasonable consensus is reached!

Sample Run!


gregarious@hal9000:~/llama_panel$ ./llama_panel.py "Are we past the AI event horizon today?"
Initializing expert panel...
Expert: mistral-small3.2 (temp: 0.0)
Panel: gemma3:4b (temp: 0.50), granite3.3:2b (temp: 0.50), qwen3:4b (temp: 0.50)

--- Expert Reasoning Step 1/20 ---
> Expert wants to use tool: 'llama_panel'
> Reason for tool selection: I need to understand the panel's perspective on the current state of AI development.

> Consulting the panel with the question: 'Are we past the AI event horizon today?'
  - Querying panelist 'gemma3:4b' (temp: 0.50)...
  - Querying panelist 'granite3.3:2b' (temp: 0.50)...
  - Querying panelist 'qwen3:4b' (temp: 0.50)...
> Panel consultation complete.

--- Expert Reasoning Step 2/20 ---
> Expert wants to use tool: 'search_web'
> Reason for tool selection: I need to find current information on whether we have passed the AI event horizon in 2025.

> Performing Google search for: 'Are we past the AI event horizon today 2025'
> Found 10 URLs.

--- Expert Reasoning Step 3/20 ---
> Expert wants to use tool: 'get_webpage'
> Reason for tool selection: This is Sam Altman's personal blog post where he discusses the AI event horizon and the gentle singularity.

> Fetching content from URL: https://blog.samaltman.com/the-gentle-singularity
> Successfully fetched and parsed content from https://blog.samaltman.com/the-gentle-singularity

--- Expert Reasoning Step 4/20 ---
> Expert wants to use tool: 'get_webpage'
> Reason for tool selection: This article provides a different perspective on whether we have crossed the AI event horizon.

> Fetching content from URL: https://www.cityam.com/have-we-crossed-the-ai-event-horizon/
> Successfully fetched and parsed content from https://www.cityam.com/have-we-crossed-the-ai-event-horizon/

--- Expert Reasoning Step 5/20 ---
> Expert wants to use tool: 'llama_panel'
> Reason for tool selection: I need to gather diverse opinions from the panel to form a consensus.

> Consulting the panel with the question: 'Based on the information provided, do you agree that we have passed the AI event horizon? Please provide reasoning.'
  - Querying panelist 'gemma3:4b' (temp: 0.50)...
  - Querying panelist 'granite3.3:2b' (temp: 0.50)...
  - Querying panelist 'qwen3:4b' (temp: 0.50)...
> Panel consultation complete.

--- Expert Reasoning Step 6/20 ---
> Expert wants to use tool: 'llama_panel'
> Reason for tool selection: I need to gather diverse opinions from the panel to form a consensus.

> Consulting the panel with the question: 'Based on the information provided, do you agree with the conclusion that while we may not have crossed the 'event horizon' in a technical sense, the rapid integration of AI into society suggests that we are on the cusp of a transformative era—one that will require both innovation and responsibility?'
  - Querying panelist 'gemma3:4b' (temp: 0.50)...
  - Querying panelist 'granite3.3:2b' (temp: 0.50)...
  - Querying panelist 'qwen3:4b' (temp: 0.50)...
> Panel consultation complete.

--- Expert Reasoning Step 7/20 ---
> Expert wants to use tool: 'final_answer'
Based on the diverse opinions gathered from the panel, we can conclude the following: 
While we may not have crossed the 'event horizon' in a technical sense—achieving
human-level AI (AGI)—AI's integration into society is rapidly transforming our world, 
blurring the lines between human and machine intelligence. The 'event horizon' 
metaphorically represents the point where AI becomes so pervasive that its impact is 
irreversible and ingrained in daily life, shaping our expectations and norms. The debate 
reflects a tension between the potential of near-term advancements and the challenges of 
achieving AGI. Balancing optimism with caution is essential as we navigate this 
transformative era of AI integration, focusing on ethical development, safety measures, 
and fostering collaboration between humans and AI to maximize benefits while mitigating 
risks.

Application, including usage and details on GitHub: GregariousEngineering/llama_panel


Up next:

Group-to-Individual thinking!

BrainBit Flappy Bird! No Coding Edition

Gemini 3 Pro + Antigravity Google released a multi-model that excels at agentic coding, and a new IDE to go with it! Naturally, I need to te...