Find answers from the community

Updated 3 months ago

How can I use Claude 3 Opus to create the property graph?

How can I use Claude 3 Opus to create the property graph?
k
C
L
10 comments
Please stand by @Callam as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
To use Claude 3 Opus to create a property graph, you need to follow several steps:

  1. Install LlamaIndex and Claude 3 Opus: First, you need to install the LlamaIndex and the specific model of Claude 3 Opus. You can do this using pip in your Python environment:
Plain Text
%pip install llama-index-llms-anthropic
!pip install llama-index

Source ()

  1. Set the Tokenizer: The next step is to set the tokenizer. You can use the Anthropic tokenizer for this:
Plain Text
from llama_index.llms.anthropic import Anthropic
from llama_index.core import Settings

tokenizer = Anthropic().tokenizer
Settings.tokenizer = tokenizer

Source ()

  1. Set the API Key: You need to set your Anthropic API key:
Plain Text
import os

os.environ["ANTHROPIC_API_KEY"] = "YOUR ANTHROPIC API KEY"

Source ()

  1. Initialize the Model: Now, you can initialize the Claude 3 Opus model:
Plain Text
from llama_index.llms.anthropic import Anthropic

llm = Anthropic(model="claude-3-opus-20240229")

Source ()

  1. Create the Property Graph: Finally, you can create the property graph using the PropertyGraphIndex class from LlamaIndex:
Plain Text
from llama_index.core import PropertyGraphIndex

index = PropertyGraphIndex.from_documents(
    documents,
    llm=llm,
    embed_model=embed_model,
    property_graph_store=graph_store,
    show_progress=True,
)

Source ()
Please replace documents, embed_model, and graph_store with your actual data, embedding model, and graph store respectively.

Remember to replace "YOUR ANTHROPIC API KEY" with your actual API key.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
@Logan M Are there any example of using opus? I don't seem to work at extracting. Like it spends tokens and runs without errors but I am guessing the format is malformed because nothing but a chunk node is added to the Neo4J graph
Oh! OK I ran into something similar. Anthropic is super weird that if it hits max tokens, it doesn't error out, but just creates an empty tool call

Try setting max_tokens to like 2000, and it should work
Pretty janky of anthropic to do us like that πŸ˜…
Okay perfect thank you!!!
you have been sooo helpful
Really appreciate your rapid responses.
Anytime πŸ‘
Add a reply
Sign up and join the conversation on Discord