#Extract the idea and question - 000034

1 messages · Page 1 of 1 (latest)

warm grove
#

I am analysing a large dataset of concepts applied to a specific domain.
These concepts may mean different things in general, and mean something very similar when applied to specific domains.
For example: “Python” and “Go”, as general terms or specifically applied on the computer science domain.

If i wanted to cluster a large dataset of computer science concepts, by retrieving their embeddings and performing kmeans or a similar algorithm. Does it make sense to pre-process the concepts and add a computer science concept before calling the embedding api?
For the example above: instead of retrieving the embeddings of “Python” and “Go”, would it make sense to retrieve the embeddings of “‘Python’ (Computer Science)” and “‘Go’ (Computer Science)”

Assuming the answer is yes, are there any relevant examples or papers on this topic?

neat knollBOT
#

Hi @warm grove. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it seems that you're interested in using OpenAI's API embeddings endpoint to generate embeddings for your dataset of computer science concepts, and then use these embeddings for clustering.

The idea of preprocessing your concepts by adding a domain-specific context (like "Computer Science") before retrieving the embeddings could potentially help in generating more domain-specific embeddings. This is because the context can help the model understand the specific sense in which the term is being used. For example, "Python" in the context of "Computer Science" would be understood differently than "Python" in the context of "Zoology".

However, the extracts do not provide any specific examples or papers that discuss this exact approach. The closest relevant information is the use of OpenAI's API embeddings endpoint for semantic search and clustering, as described in the OpenAI Cookbook's Clustering example (https://cookbook.openai.com/examples/clustering) and the OpenAI API embeddings endpoint guide (https://beta.openai.com/docs/guides/embeddings).

Here's a simplified example of how you might use the embeddings for clustering, based on the extracts:

import numpy as np
import pandas as pd
from sklearn.cluster import KMeans
from ast import literal_eval

# Assuming df is your DataFrame and "embedding" is the column with the embeddings
df["embedding"] = df.embedding.apply(literal_eval).apply(np.array) # convert string to numpy array
matrix = np.vstack(df.embedding.values)

kmeans = KMeans(n_clusters = 4, init='k-means++', random_state=42)
kmeans.fit(matrix)
df['Cluster'] = kmeans.labels_
#

For more detailed and specific guidance, you might want to refer to the full OpenAI documentation and examples, or consider reaching out to the OpenAI community or support.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: