File size: 1,996 Bytes
74304f0
 
 
 
6a41a41
a554a4e
 
 
74304f0
 
042d836
74304f0
 
5b33b3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: Algorithm Finder
emoji: 🔍
colorFrom: blue
colorTo: blue
sdk: gradio
sdk_version: "6.19.0"
python_version: "3.10"
app_file: app.py
pinned: false
hardware: zero-gpu
---

# Algorithm Finder

Find the best algorithm for any code/math problem using LLM-powered C++ agents, compiled and benchmarked locally (Zero GPU).

## How It Works

1. **Initial Coder**: Generates a compilable C++ solution for your problem.
2. **Researcher**: Generates N novel alternative C++ algorithms.
3. **Validator**: Evaluates all candidates against performance metrics and selects a winner.
   - If no winner passes, it regenerates N new algorithms (up to `max_validation_rounds`).
4. **Real-World Tester**: Tests the winner against the baseline in N realistic scenarios.
5. **Summary**: Displays a Markdown summary of the winning algorithm and results.

## Setup

### Local

```bash
pip install -r requirements.txt
python app.py
```

### Hugging Face Spaces (Zero GPU)

1. Create a new Space with the **Gradio** SDK.
2. Set `app.py` as the entrypoint.
3. Add `requirements.txt`.
4. (Optional) Add your `HF_TOKEN` as a Space secret.
5. Deploy.

## Usage

- **Problem Description**: Describe the problem you want to optimize.
- **Objective**: What you are trying to optimize (speed, memory, accuracy, etc.).
- **User-defined Metric**: A custom metric the validator should prioritize.
- **Model ID**: Any Hugging Face Instruct model (e.g., `meta-llama/Meta-Llama-3-8B-Instruct`).
- **Number of candidate algorithms**: How many new algorithms the researcher generates per round.
- **Number of real-world scenarios**: How many scenarios the winner is tested in.
- **Max validation rounds**: How many times to regenerate if no winner is found.

## Notes

- This app uses the **Hugging Face Inference API** (free tier or Pro) to run LLMs.
- C++ compilation happens locally using `g++`.
- Execution time and memory usage are measured for each algorithm.
- All code is generated and executed within the app sandbox.