Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support embedding size in config settings #92

Open
gaocegege opened this issue Jun 2, 2023 · 2 comments · May be fixed by #87
Open

feat: Support embedding size in config settings #92

gaocegege opened this issue Jun 2, 2023 · 2 comments · May be fixed by #87
Assignees

Comments

@gaocegege
Copy link

# https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html#create-a-generative-character
def create_new_memory_retriever(ctx: Context):
    """Create a new vector store retriever unique to the agent."""
    # Define your embedding model
    embeddings_model = load_embedding_from_config(ctx.settings.model.embedding)
    # Initialize the vectorstore as empty
    embedding_size = 1536
    index = faiss.IndexFlatL2(embedding_size)
    vectorstore = FAISS(
        embeddings_model.embed_query,
        index,
        InMemoryDocstore({}),
        {},
        relevance_score_fn=relevance_score_fn,
    )
    return TimeWeightedVectorStoreRetriever(
        vectorstore=vectorstore, other_score_keys=["importance"], k=15
    )

Now 1536 is hard-coded.

@tonyz0x0
Copy link
Collaborator

tonyz0x0 commented Jun 3, 2023

Sure will make a PR for supporting this

@tonyz0x0
Copy link
Collaborator

tonyz0x0 commented Jun 3, 2023

The PR: #87 allows user define the embedding_size in EmbeddingSettings class, for example:

# skyagi/src/skyagi/model.py
EmbeddingSettings(
    type=EmbeddingType.OpenAIEmbeddings,
    provider=ModelProvider.OpenAI,
    name="openai-text-embedding-ada-002",
    args={"model": "text-embedding-ada-002"},
    embedding_size=1536
)

@tonyz0x0 tonyz0x0 linked a pull request Jun 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants