FunMinks — utilities around LLM endpoints and mink population tools.
Project description
FunMinks: Genetic Algorithm Utilities for LLMs
FunMinks is a Python package for symbolic regression and genetic algorithm experimentation using Large Language Models (LLMs). It provides tools to define, mutate, and evolve code-based individuals ("minks") and manage populations, leveraging LLMs for code generation and mutation.
What is FunMinks?
FunMinks enables evolutionary computation on code snippets, using LLMs to mutate and optimize Python functions to fit target data. It is designed for symbolic regression, automated code improvement, and research in genetic programming with LLMs.
- Mink: An individual represented by a genome (Python code), evaluated for fitness against datapoints.
- Population: A collection of minks, managed for selection, mutation, and evolution.
- LLM Endpoint: Utilities to load and interact with local LLM models for code generation.
Features
- Symbolic regression using genetic algorithms and LLMs
- Population management and selection
- Code mutation via LLM prompts
- Fitness evaluation against custom datapoints
- Extensible for custom genetic operations
Installation
It is recommended to use a virtual environment for isolation:
# Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\Activate.ps1
# Install FunMinks and dependencies
pip install -e .
Or install from source:
pip install git+https://github.com/UGarCil/GeneticAlgoLLM.git
Requirements
- Python >= 3.10
- transformers
- pandas
- huggingface_hub
- torch (optional, see below)
If you need GPU support, install the appropriate version of torch:
pip install torch --extra-index-url https://download.pytorch.org/whl/cu118
Usage
1. Prepare Data and Templates
- Place your datapoints in
templates/datapoints.csv(two columns: x, y) - Use or modify
templates/prompt_template.txtfor LLM mutation prompts - Use
templates/seed_code_template.txtas the initial genome
2. Load LLM Endpoint
from FunMinks.llm_endpoint import load_llm
llm_params = load_llm('path/to/your/model')
3. Create a Population
from FunMinks.population import Population
from FunMinks.mink_llm_based import Mink
# Load templates and datapoints
with open('templates/prompt_template.txt') as f:
prompt = f.read()
with open('templates/seed_code_template.txt') as f:
seed_code = f.read()
with open('templates/datapoints.csv') as f:
datapoints = f.read()
# Initialize population
pop = Population(
pop_size=20,
seed_code=seed_code,
datapoints=datapoints,
prompt=prompt,
llm_params=llm_params
)
4. Run Evolution
for generation in range(10):
pop.run_episode()
print(f"Generation {generation}: Avg fitness = {pop.avg_fitness}")
Project Structure
FunMinks/
mink_llm_based.py # Mink class (individual)
population.py # Population management
llm_endpoint.py # LLM loading utilities
icons/
main_logo.png # Project logo
templates/
datapoints.csv # Example data
prompt_template.txt # LLM prompt template
seed_code_template.txt # Initial code genome
License
This project is licensed under the MIT License. See LICENSE for details.
Author
Uriel Garcilazo Cruz
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file funminks-0.1.1.tar.gz.
File metadata
- Download URL: funminks-0.1.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e02a6da6533910965b9b29b822b6316e8984b6faa3368a413070ea9a8b3dca7
|
|
| MD5 |
86c1796504eb366af71321e5060739df
|
|
| BLAKE2b-256 |
31eed0069b0395a45d173d97991d2ac56a0ec4d0f455ae905173956b1164e89c
|
File details
Details for the file funminks-0.1.1-py3-none-any.whl.
File metadata
- Download URL: funminks-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
435a508542fd1792bbfd03545ff61dc0f07c11c3d16d76424b1fe27f14cdde6e
|
|
| MD5 |
9f4ee87551e36e6ed9183fba806dc421
|
|
| BLAKE2b-256 |
55798ccd7a96d71d3b0892f78689f3716cc0673d0d23e3e068aa2573a5c14cbb
|