Label, clean and enrich text datasets with LLMs
Project description
PromptMeteo
Promptmeteo is a Python library build over LangChain to build prompts and LLMs by configuration parameters. The goal of this project is to be used as a template to industrialize LLM projects.
๐ฅ๐ง
Dammed to chains for bringing humans the lightInstallation
~/promptmeteo$ make setup
Quick start
from promptmeteo import Promptmeteo
model = Promptmeteo(
task_type = 'classification',
model_provider_name = 'hf_pipeline',
model_name = 'google/flan-t5-small',
selector_algorithm = 'semantic_similarity',
selector_k = 3
)
model = model.train(
examples = ['estoy feliz', 'me da igual', 'no me gusta'],
annotations = ['positivo', 'neutral', 'negativo'],
)
model.predict(['que guay!!'])
>>> [[positive]]
Build project
Build image and run container
$ docker build -t promptmeteo .
$ docker run -it promptmeteo bash
Run example
$ python examples/getting_started.py --data_path data/classification_data.csv --prompt_path prompts/classification.yml
Run test
$ python -m pytest tests
Project Structure
promptmeteo
โโโ data
โย ย โโโ classification_data.csv
โโโ Dockerfile
โโโ examples
โย ย โโโ getting_started.py
โโโ LICENSE
โโโ Makefile
โโโ prompts
โย ย โโโ classification.yml
โย ย โโโ ner_prompt.yml
โโโ pyproject.toml
โโโ README.md
โโโ requirements.txt
โโโ src
โย ย โโโ promptmeteo
โย ย โโโ __init__.py
โย ย โโโ main.py
โย ย โโโ models
โย ย โย ย โโโ base.py
โย ย โย ย โโโ fake_llm.py
โย ย โย ย โโโ hf_hub_api.py
โย ย โย ย โโโ hf_pipeline.py
โย ย โย ย โโโ __init__.py
โย ย โย ย โโโ openai.py
โย ย โโโ parsers
โย ย โย ย โโโ classification_parser.py
โย ย โย ย โโโ dummy_parser.py
โย ย โย ย โโโ __init__.py
โย ย โโโ prompts
โย ย โย ย โโโ base.py
โย ย โย ย โโโ classification_prompt.py
โย ย โย ย โโโ __init__.py
โย ย โย ย โโโ ner_prompt.py
โย ย โย ย โโโ templates
โย ย โย ย โโโ en
โย ย โย ย โโโ __init__.py
โย ย โย ย โโโ sp
โย ย โย ย โโโ classification_prompt.yml
โย ย โย ย โโโ __init__.py
โย ย โย ย โโโ ner_prompt.yml
โย ย โโโ selector
โย ย โย ย โโโ __init__.py
โย ย โย ย โโโ length_selector.py
โย ย โย ย โโโ marginal_relevance_selector.py
โย ย โย ย โโโ n_gram_selector.py
โย ย โย ย โโโ semantic_similarity_selector.py
โย ย โโโ tasks
โย ย โโโ base.py
โย ย โโโ classification_task.py
โย ย โโโ __init__.py
โย ย โโโ ner_task.py
โโโ tests
โโโ test_main.py
โโโ test_models.py
โโโ test_parsers.py
โโโ test_prompts.py
โโโ test_selectors.py
โโโ test_task.py
Objects
classDiagram
Promptmeteo ..|> TaskBuilder : Composition
TaskBuilder ..|> Task : Build
ClassificationTask --|> Task : Inheritance
Task ..|> PromptFactory : Composition
Task ..|> ParserFactory : Composition
Task ..|> SelectorFactory : Composition
Task ..|> ModelFactory : Composition
Prompt ..|> PromptFactory : Instanciate
Parser ..|> ParserFactory : Instanciate
Selector ..|> SelectorFactory : Instanciate
Model ..|> ModelFactory : Instanciate
class Promptmeteo{
+ builder : TaskBuilder
+ train(examples : List[str], annotations : List[str])
+ predict(examples : List[str])
}
class TaskBuilder{
+ task : Task
- _build_model()
- _build_pormpt()
- _build_parser()
- _build_selector()
}
class Task{
+ model : Model
+ prompt : Prompt
+ parser : Parser
+ selector : Selector
+ run(prompt: str)
}
class ClassificationTask{
+ model : Model
+ prompt : Prompt
+ parser : Parser
+ selector : Selector
+ run(prompt: str)
}
class PromptFactory{
+ factory_method() -> Prompt
}
class ParserFactory{
+ factory_method() -> Parser
}
class ModelFactory{
+ factory_method() -> Model
}
class SelectorFactory{
+ factory_method() -> Selector
}
class Prompt{
+ PROMPT_EXAMPLE
+ run()
}
class Parser{
+ run()
}
class Model{
+ llm
+ run(prompt: str)
}
class Selector{
+ example_selector
+ run(prompt: str)
}
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
promptmeteo-0.0.0.tar.gz
(19.3 kB
view hashes)
Built Distribution
Close
Hashes for promptmeteo-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f1ec38021557508d6c7b6a37405a8ad9e0742e0c22d10fef84c005e11649018 |
|
MD5 | 715415c9b3f6a8a0613d1a4ddabb9c4a |
|
BLAKE2b-256 | 3f7ba6be7bc1f106e48ff71696472ca11d021157301b1a58317161d9713cc800 |