LLM evaluations and synthetic data generation with the MAIHEM models
Project description
maihem
Introduction
The maihem python package allows you to generate synthetic text data for training and evaluating your LLMs.
Getting Started
Installation
To install the API, run the following command:
pip install maihem
Obtaining your maihem API key
Get a free API key by subscribing to our product here: www.maihem.ai.
Setting API key
Before using the maihem package, you need to set your maihem API key as an environment variable. You can add it directly in your python code, or to your local bash script.
Alternative 1: In python code
In the beggining of your code add the following lines with your corresponding API key:
import os
os.environ['MAIHEM_API_KEY'] = '<your_maihem_api_key>'
Alternative 2: In local bash script
For Linux:
Open the .bashrc file in your home directory with a text editor
vim ~/.bashrc
add the following line to the file with your corresponding API key:
export MAIHEM_API_KEY = '<your_maihem_api_key>'
Run the following command in the terminal to apply the changes
source ~/.bashrc
For Mac:
Open the .bash_profile file in your home directory with a text editor
vim ~/.bash_profile
add the following line to the file with your corresponding API key:
export MAIHEM_API_KEY = '<your_maihem_api_key>'
Run the following command in the terminal to apply the changes
source ~/.bash_profile
Generate synthetic data
Persona prompts
See run_examply.py for an example python script for persona prompt generation. The example code is also below
import os
import maihem as mh
os.environ['MAIHEM_API_KEY'] = 'a923c14d881247a7bad58b93d9595494'
# Parameter dictionary for intent
intent = {
'intent': "unblock credit card",
'context': "credit card got blocked when traveling abroad",
'category': "retail banking"
}
# Parameter dictionary for persona
persona = {
'mood': "angry",
'age': "30-40",
'gender': "male",
'ethnicity': "white",
'disability': "none",
'income': "high",
'education': "college degree",
'marital_status': "married",
'children': "2",
'employment': "employed",
'housing': "rent",
'occupation': "data scientist",
'location': "New York",
'customer_name': "John Doe",
}
# Create data generator object
dg = mh.DataGenerator()
# Generate list of prompts for defined persona
data = dg.generate_prompts(intent, persona, model_temperature=0.8, n_calls=3, n_prompts_per_call=2)
print(data)
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
File details
Details for the file maihem-1.0.1.tar.gz
.
File metadata
- Download URL: maihem-1.0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bafc365c132f33632b973c2189e9fbeba99849208a57d9a5225a63c35021b36d |
|
MD5 | 1d209e140deaf3f6da23249abea9270e |
|
BLAKE2b-256 | 0f7e14bb5c6711d2102733e10cbac92213b3c17f89a44410eec785ee22b88155 |
File details
Details for the file maihem-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: maihem-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf631a9d2a90dd6d0edf1bdc5832c822563788b2c44c29a290765ba80e6d0609 |
|
MD5 | 6aecdb1c0e997296e6d1ef032de94ddb |
|
BLAKE2b-256 | 723afb2ae19dd97e1b16396e431c626e5aeca1966c0f90e430a690faf883614f |