An open-source LLM for food product development.
FoodLM is an open-source LLM and retrieval system built to reason about food formulations. It turns ingredient labels and product-development goals into constraint-compliant substitutions, transparent rankings, and grounded product-formulation plans.
Built from the ground up for food R&D, FoodLM combines a domain-specific ingredient ontology, food embeddings, retrieval and ranking, substitution rules, formulation constraints, a validated training dataset, QLoRA fine-tuning pipeline, evaluation harness, and live application. The goal is to build a language model that understands how food products are formulated, reformulated, and developed.
Try FoodLM · Architecture · Evaluation · Dataset · Model
Changing an ingredient is rarely a one-to-one substitution.
Ingredients affect texture, sweetness, structure, processing, nutrition, labeling, cost, shelf life, and sensory performance. A useful AI system for product development needs more than general language knowledge. It needs a way to understand ingredients, identify their role in a formula, retrieve viable alternatives, apply development constraints, and reason over the remaining options.
FoodLM is built around that workflow.
Ingredient label
↓
Ingredient resolution
↓
Hybrid candidate retrieval
↓
Product constraints
↓
Multi-signal ranking
↓
FoodLM generation
↓
Grounded formulation plan
The language model does not decide which ingredients are permissible.
FoodLM first resolves the formula, retrieves candidate substitutions, applies hard constraints, and ranks the viable alternatives. The model then reasons over that approved candidate set and produces a structured formulation plan.
Give FoodLM an ingredient list and a product-development objective:
wheat flour, cane sugar, butter, egg, cocoa powder
Then choose a goal such as:
- Reduce sugar
- Remove allergens
- Improve protein
- Simplify the formula
- Explore lower-cost ingredients
- Explore cleaner-label alternatives
FoodLM:
- Resolves ingredient names against a canonical food ontology
- Identifies ingredients relevant to the development goal
- Retrieves functionally plausible substitution candidates
- Applies goal-specific formulation constraints
- Ranks the remaining alternatives using multiple signals
- Provides evidence and tradeoffs for each recommendation
- Generates a grounded reformulation plan
- Validates generated substitutions against the approved candidate set
The result is not an unconstrained chatbot response. It is a formulation plan grounded in the system's ingredient knowledge, retrieval results, and product-development rules.
FoodLM includes a structured domain layer for ingredient reasoning.
The current engine contains:
- 175 canonical ingredients
- 209 ingredient aliases
- Functional metadata
- Ingredient categories
- Substitution relationships
- 49 substitution-rule targets
Real ingredient labels are resolved against this ontology before retrieval begins.
FoodLM combines semantic ingredient retrieval with curated substitution knowledge.
This allows the system to use learned similarity while preserving explicit food-domain relationships that should not depend on embedding distance alone.
Product-development requirements are applied before generation.
Current goals include constraints related to:
- Sugar
- Allergens
- Protein
- Cost
- Ingredient simplification
- Cleaner-label reformulation
Candidates that violate the development objective can be removed before they reach the model.
Candidate substitutions retain their scoring signals, evidence, confidence, and tradeoffs.
This makes the recommendation path inspectable rather than hiding the decision inside a language-model response.
FoodLM includes a reproducible model-development pipeline for domain adaptation.
The training stack targets Qwen3-8B with QLoRA and includes:
- Validated food-product-development instruction data
- Dataset generation and validation
- QLoRA training configuration
- Adapter-aware inference
- Candidate-locked generation
- Structured output validation
- Comparative evaluation tooling
The current public dataset contains 1,700 validated instruction records.
The architecture keeps the model layer replaceable. FoodLM can operate with deterministic generation, local inference, a configured model endpoint, provider-backed inference, or an adapted model behind the same system contract.
Read the model card · See the training pipeline
FoodLM separates probabilistic language generation from deterministic product constraints.
flowchart LR
A[Ingredient label] --> B[Parser and ontology resolver]
B --> C[Hybrid retrieval]
C --> D[Constraint engine]
D --> E[Candidate ranking]
E --> F[Approved candidate context]
F --> G[LLM]
F --> H[Deterministic fallback]
G --> I[Schema and grounding validator]
I --> J[Formulation plan]
H --> J
This creates several important control points:
- Constraints run before generation. Product requirements filter the candidate set upstream.
- Generation is candidate-locked. The model can select only from approved targets and replacements.
- Outputs are validated. Unsupported substitutions and malformed plans can be rejected.
- The system has a deterministic fallback. Core reformulation logic does not depend on an external model being available.
The LLM is therefore part of the reasoning system, not the authority that defines what substitutions are allowed.
FoodLM includes versioned benchmark datasets, evaluation runners, committed result artifacts, regression tests, and automated claim verification.
| Evaluation | Result |
|---|---|
| Ingredient-resolution precision | 1.0000 |
| Ingredient-resolution recall | 0.9905 |
| Ingredient-resolution F1 | 0.9952 |
| Acceptable substitution in top three | 1.0000 |
| Zero prohibited substitutions | 1.0000 |
| JSON-schema validity | 1.0000 |
Current evaluation coverage:
30 resolution cases · 30 retrieval cases · 20 generation-integrity cases · 1,700 validated instruction records · 175 canonical ingredients · 209 aliases · 49 substitution-rule targets
Results are produced from committed benchmark artifacts rather than manually entered claims.
These benchmarks measure the bounded public evaluation suite. They are not claims of independent sensory validation, food-science correctness, or production readiness.
See the full evaluation methodology and results
The live Reformulation Copilot provides a browser interface to the FoodLM system.
No account or API key is required for the browser demo.
Or run the project locally:
git clone https://github.com/stevencallaway1/foodlm
cd foodlm
pip install -e ".[ui]"
python app_gradio.pyUse FoodLM from Python:
from foodlm import Reformulator
foodlm = Reformulator(live_embeddings=False)
plan = foodlm.reformulate(
"wheat flour, cane sugar, butter, egg",
"reduce_sugar",
)The public ingredient dataset is intentionally replaceable.
FoodLM can be adapted to reason over private product-development knowledge such as:
- Ingredient specifications
- Approved suppliers
- Existing formulas
- Historical product-development work
- Cost and availability data
- Processing constraints
- Sensory evidence
- Company substitution policies
- Internal formulation rules
- Evaluation datasets
- Private model adapters
- Private inference endpoints
foodlm = Reformulator(
data_dir="/path/to/company-data",
live_embeddings=False,
)This creates a path from the public FoodLM project to a company-specific system built around proprietary formulation knowledge.
src/foodlm/ Ingredient ontology, retrieval, constraints, ranking, and generation
training/ Dataset validation and QLoRA training pipeline
benchmarks/ Evaluation datasets, runners, and committed results
tests/ Engine, data, model, distribution, and UI coverage
web/ FoodLM site and browser-based Reformulation Copilot
deploy/space/ Application deployment configuration
Architecture · Evaluation · Dataset card · Model card · Customization · Training · Deployment
FoodLM is designed as R&D decision-support software for food product development.
Ingredient substitution can affect processing, sensory performance, nutrition, stability, packaging, labeling, and shelf life. Recommendations should be reviewed by qualified food scientists and validated through appropriate bench testing before production use.
FoodLM source code is licensed under the MIT License.
The synthetic instruction dataset is released under CC BY 4.0.
The model-development path targets Qwen3-8B under its upstream Apache-2.0 license. Optional ingredient retrieval can integrate Kaikaku's Epicure embeddings, which were trained by their upstream authors on a 4.14 million-recipe corpus spanning eight languages and are released under CC BY 4.0.
See CITATION.cff for citation and attribution metadata.
Built by Steven Callaway.