{"id":25691906,"url":"https://github.com/plexe-ai/smolmodels","last_synced_at":"2025-02-24T23:02:54.694Z","repository":{"id":271270889,"uuid":"912499477","full_name":"plexe-ai/smolmodels","owner":"plexe-ai","description":"✨ build ml models in natural language and minimal code","archived":false,"fork":false,"pushed_at":"2025-02-18T13:42:03.000Z","size":679,"stargazers_count":522,"open_issues_count":6,"forks_count":26,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-02-18T14:34:23.661Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://plexe.ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plexe-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-05T18:34:25.000Z","updated_at":"2025-02-18T13:25:27.000Z","dependencies_parsed_at":"2025-01-06T17:51:05.055Z","dependency_job_id":"6caff6b8-938e-4698-bbe1-e7925c4e50e6","html_url":"https://github.com/plexe-ai/smolmodels","commit_stats":null,"previous_names":["plexe-ai/smolmodels"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plexe-ai%2Fsmolmodels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plexe-ai%2Fsmolmodels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plexe-ai%2Fsmolmodels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plexe-ai%2Fsmolmodels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plexe-ai","download_url":"https://codeload.github.com/plexe-ai/smolmodels/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240571032,"owners_count":19822412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-24T23:02:00.582Z","updated_at":"2025-02-24T23:02:54.687Z","avatar_url":"https://github.com/plexe-ai.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# smolmodels ✨\n\n[![PyPI version](https://img.shields.io/pypi/v/smolmodels.svg)](https://pypi.org/project/smolmodels/)\n[![Discord](https://img.shields.io/discord/1300920499886358529?logo=discord\u0026logoColor=white)](https://discord.gg/SefZDepGMv)\n\nBuild machine learning models using natural language and minimal code\n\n[Quickstart](#1-quickstart) |\n[Features](#2-features) |\n[Installation \u0026 Setup](#3-installation--setup) |\n[Documentation](#4-documentation) |\n[Benchmarks](#5-benchmarks)\n\n\u003cbr\u003e\n\nCreate machine learning models with minimal code by describing what you want them to do in\nplain words. You explain the task, and the library builds a model for you, including data generation, feature \nengineering, training, and packaging.\n\u003c/div\u003e\n\n\u003e [!NOTE]\n\u003e This library is in early development, and we're actively working on new features and improvements! Please report any\n\u003e bugs or share your feature requests on [GitHub](https://github.com/plexe-ai/smolmodels/issues) \n\u003e or [Discord](https://discord.gg/SefZDepGMv) 💛\n\n\n## 1. Quickstart\nInstallation: \n\n```bash\npip install smolmodels\n```\n\nDefine, train and save a `Model`:\n\n```python\nimport smolmodels as sm\n\n# Step 1: define the model\nmodel = sm.Model(\n    intent=\"Predict sentiment on a news article such that [...]\",\n    input_schema={\"headline\": str, \"content\": str},         # [optional - can be pydantic or dict]\n    output_schema={\"sentiment\": str}                        # [optional - can be pydantic or dict]\n)\n\n# Step 2: build and train the model on data\nmodel.build(\n   datasets=[dataset, auxiliary_dataset],\n   provider=\"openai/gpt-4o-mini\",\n   timeout=3600\n)\n\n# Step 3: use the model to get predictions on new data\nsentiment = model.predict({\n   \"headline\": \"600B wiped off NVIDIA market cap\",\n   \"content\": \"NVIDIA shares fell 38% after [...]\",\n})\n\n# Step 4: save the model, can be loaded later for reuse\nsm.save_model(model, \"news-sentiment-predictor\")\n\n# Step 5: load a saved model and use it\nloaded_model = sm.load_model(\"news-sentiment-predictor.tar.gz\")\n```\n\n## 2. Features\n\n`smolmodels` combines graph search, LLM code/data generation and code execution to produce a machine learning model\nthat meets the criteria of the task description. When you call `model.build()`, the library generates a graph of\npossible model solutions, evaluates them, and selects the one that maximises the performance metric for this task.\n\n### 2.1. 💬 Define Models using Natural Language\nA model is defined as a transformation from an **input schema** to an **output schema**, which behaves according to an\n**intent**. The schemas can be defined either using `pydantic` models, or plain dictionaries that are convertible to\n`pydantic` models.\n\n```python\n# This defines the model's identity\nmodel = sm.Model(\n    intent=\"Predict sentiment on a news article such that [...]\",\n    input_schema={\"headline\": str, \"content\": str},                 # supported: pydantic or dict\n    output_schema={\"sentiment\": str}                                # supported: pydantic or dict\n)\n```\n\nYou describe the model's expected behaviour in plain English. The library will select a metric to optimise for, \nand produce logic for feature engineering, model training, evaluation, and so on.\n\n### 2.2. 🎯 Model Building\nThe model is built by calling `model.build()`. This method takes one or more datasets and \ngenerates a set of possible model solutions, training and evaluating them to select\nthe best one. The model with the highest performance metric becomes the \"implementation\" of the predictor.\n\nYou can specify the model building cutoff in terms of a timeout, a maximum number of solutions to explore, or both.\n\n```python\nmodel.build(\n    datasets=[dataset_a, dataset_b],\n    provider=\"openai/gpt-4o-mini\",\n    timeout=3600,                       # [optional] max time in seconds\n    max_iterations=10                   # [optional] max number of model solutions to explore\n)\n```\n\nThe model can now be used to make predictions, and can be saved or loaded using `sm.save_model()` or `sm.load_model()`.\n\n```python\nsentiment = model.predict({\"headline\": \"600B wiped off NVIDIA market cap\", ...})\n```\n\n### 2.3. 🎲 Data Generation and Schema Inference\nThe library can generate synthetic data for training and testing. This is useful if you have no data available, or \nwant to augment existing data. You can do this with the `sm.DatasetGenerator` class:\n\n```python\ndataset = sm.DatasetGenerator(\n    schema={\"headline\": str, \"content\": str, \"sentiment\": str},  # supported: pydantic or dict\n    data=existing_data\n)\ndataset.generate(1000)\n\nmodel.build(\n    datasets=[dataset],\n    ...\n)\n```\n\n\u003e [!CAUTION]\n\u003e Data generation can consume a lot of tokens. Start with a conservative `generate_samples` value and\n\u003e increase it if needed.\n\nThe library can also infer the input and/or output schema of your predictor, if required. This is based either on the\ndataset you provide, or on the model's intent. This can be useful when you don't know what the model should look like.\nAs with the models, you can specify the schema using `pydantic` models or plain dictionaries.\n\n```python\n# In this case, the library will infer a schema from the intent and generate data for you\nmodel = sm.Model(intent=\"Predict sentiment on a news article such that [...]\")\nmodel.build(provider=\"openai/gpt-4o-mini\")\n```\n\n\u003e [!TIP]\n\u003e If you know how the model will be used, you will get better results by specifying the schema explicitly.\n\u003e Schema inference is primarily intended to be used if you don't know what the input/output schema at prediction time\n\u003e should be.\n\n### 2.4. 🌐 Multi-Provider Support\nYou can use multiple LLM providers for model generation. Specify the provider and model in the format `provider/model`:\n\n```python\nmodel.build(provider=\"openai/gpt-4o-mini\", ...)\n```\n\nSee the section on installation and setup for more details on supported providers and how to configure API keys.\n\n## 3. Installation \u0026 Setup\nInstall the library in the usual manner:\n\n```bash\npip install smolmodels\n```\n\nSet your API key as an environment variable based on which provider you want to use. For example:\n\n```bash\n# For OpenAI\nexport OPENAI_API_KEY=\u003cyour-API-key\u003e\n# For Anthropic\nexport ANTHROPIC_API_KEY=\u003cyour-API-key\u003e\n# For Gemini\nexport GEMINI_API_KEY=\u003cyour-API-key\u003e\n```\n\n\u003e [!TIP]\n\u003e The library uses LiteLLM as its provider abstraction layer. For other supported providers and models,\n\u003e check the [LiteLLM](https://docs.litellm.ai/docs/providers) documentation.\n\n## 4. Documentation\nFor full documentation, visit [docs.plexe.ai](https://docs.plexe.ai).\n\n## 5. Benchmarks\nPerformance evaluated on 20 OpenML benchmark datasets and 12 Kaggle competitions. Higher performance observed on 12/20\nOpenML datasets, with remaining datasets showing performance within 0.005 of baseline. Experiments conducted on standard\ninfrastructure (8 vCPUs, 30GB RAM) with 1-hour runtime limit per dataset.\n\nComplete code and results are available at [plexe-ai/plexe-results](https://github.com/plexe-ai/plexe-results).\n\n## 6. Contributing\n\nWe love contributions! You can get started with [issues](https://github.com/plexe-ai/smolmodels/issues),\nsubmitting a PR with improvements, or joining the [Discord](https://discord.gg/3czW7BMj) to chat with the team. \nSee [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.\n\n## 7. License\n\nApache-2.0 License - see [LICENSE](LICENSE) for details.\n\n## 8. Product Roadmap\n\n- [X] Fine-tuning and transfer learning for small pre-trained models\n- [ ] Support for non-tabular data types in model generation\n- [ ] Use Pydantic for schemas and split data generation into a separate module\n- [ ] Smolmodels self-hosted platform ⭐ (More details coming soon!)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplexe-ai%2Fsmolmodels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplexe-ai%2Fsmolmodels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplexe-ai%2Fsmolmodels/lists"}