A Software Engineer's Guide to Hugging Face aisheets
Huggingface/aisheets is a library that allows you to easily build, enrich, and transform datasets using AI models, without writing any code. It's essentially a no-code tool for data manipulation using the power of Hugging Face models. It's built on top of the popular pandas library, which makes it easy to integrate into your existing data pipelines.
Huggingface/aisheets can be incredibly useful for software engineers, especially those working with data. Here are a few reasons why
Rapid Prototyping
You can quickly and easily prototype new features or models without spending a lot of time on data preparation. This is especially useful for quickly testing out new ideas.
Data Augmentation
You can use it to augment your datasets with synthetic data, which can be useful for training models when you have limited data.
Automated Data Cleaning
You can use AI models to automatically clean and normalize your data, which can save you a lot of time and effort.
Reduced Development Time
By automating many of the data manipulation tasks, you can significantly reduce the time it takes to develop and deploy new features or models.
Here's a step-by-step guide on how to get started with huggingface/aisheets
Installation
You can install the library using pip
pip install aisheets
Basic Usage
The library is built on top of pandas, so you can start by creating a pandas DataFrame. Then, you can use the AISheets class to enrich or transform your data.
import pandas as pd
from aisheets import AISheets
# Create a sample DataFrame
df = pd.DataFrame({
'text': [
'I love this product!',
'This is the worst movie I have ever seen.',
'The food was terrible.',
]
})
# Initialize AISheets
ais = AISheets()
# Enrich the DataFrame with sentiment analysis
df_with_sentiment = ais.enrich(
df,
model='distilbert-base-uncased-finetuned-sst-2-english',
prompt='sentiment analysis',
columns={'text': 'sentiment'}
)
print(df_with_sentiment)
Here's an example of how you can use huggingface/aisheets to generate synthetic data. This can be useful when you have a small dataset and want to augment it with more examples to improve your model's performance.
import pandas as pd
from aisheets import AISheets
# Initialize AISheets
ais = AISheets()
# Create a sample DataFrame with a few examples
df = pd.DataFrame({
'headline': [
'Tesla stock soars after earnings report',
'New study finds link between coffee and longevity',
'Global temperatures hit record highs in July'
]
})
# Generate 5 more synthetic headlines
synthetic_df = ais.generate(
df,
model='t5-base',
prompt='Generate a new news headline about a company or a scientific discovery.',
num_samples=5
)
print(synthetic_df)
This example uses the generate function to create new data based on the prompt and the examples provided in the initial DataFrame. The model t5-base is a general-purpose text generation model that can create a wide variety of text, making it perfect for this task.