Skip to content

Instantly share code, notes, and snippets.

@fsndzomga
Created September 12, 2023 11:37
Show Gist options
  • Save fsndzomga/3933c1c72ba46b2d93a5b62e4aefdf28 to your computer and use it in GitHub Desktop.
Save fsndzomga/3933c1c72ba46b2d93a5b62e4aefdf28 to your computer and use it in GitHub Desktop.
Data enrichment
llm = ChatOpenAI(max_tokens=200)
newsgroups_train_enriched = []
data = newsgroups_train.data
for index in range(len(data)):
# ... (Data preprocessing)
messages = [
SystemMessage(content="You are a helpful assistant that classifies texts."),
HumanMessage(content=f"Give one category to the following text: {text}. The category should be among this list: {categories}")
]
response = llm(messages)
newsgroups_train_enriched.append(text + response.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment