This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datasets import load_dataset | |
import csv | |
from happytransformer.happy_question_answering import HappyQuestionAnswering | |
def main(): | |
# Be careful not to commit the csv files to the rep | |
train_csv_path = "train.csv" | |
eval_csv_path = "eval.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from happytransformer import HappyTextClassification | |
from datasets import load_dataset | |
import csv | |
# Colab: https://colab.research.google.com/drive/1z8m5QYi2tcQLd3m_fESK37SYbMBSqTO7?usp=sharing | |
def run_finetune(): | |
train_csv_path = "train.csv" | |
eval_csv_path = "eval.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install gender-guesser | |
from gender_guesser.detector import Detector | |
gender_detector = Detector() | |
names = ["Eric", "Kylie", "Spencer", "Erin"] | |
for name in names: | |
result = gender_detector.get_gender(name) | |
print(name + ":", result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install transformers | |
from transformers import pipeline | |
tags = ["travel", "surfing", "Indonesia", "Bali", "cryptocurrencies", "bitcoin", "mining", "gardening", "plants"] | |
sequences = ["Best surf camp in Bali", "How do I build a crypto mining rig?", "my plant has yellow leaves"] | |
classifer = pipeline("zero-shot-classification") | |
for text in sequences: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install happytransformer | |
from happytransformer import HappyGeneration | |
happy_gen = HappyGeneration("GPT-NEO", "EleutherAI/gpt-neo-125M") | |
result = happy_gen.generate_text("What is natural language processing?") | |
print(result.text) | |
# ---------------------------- | |
# Result: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In terminal | |
# pip install happytransformer | |
# Python code below | |
#------------------------------------------------------------------------------------------------------------------------------ | |
# Casual to Formal | |
#------------------------------------------------------------------------------------------------------------------------------ | |
from happytransformer import HappyTextToText |