Releases: neo4j/neo4j-graphrag-python
Neo4j GraphRAG Package for Python 1.8.0
New in 1.8.0
Full Changelog: 1.7.0...1.8.0
Schema
-
Introduced a new
GraphSchema
object -
GraphSchema
object can be serialized as json or yaml -
Extra parameters have been added to the
GraphSchema
object to control how the LLM-extracted graph is cleaned in a post-processing step. This replaces the "STRICT mode" introduced in 1.7.0. -
SchemaExtractionFromText: an automatic schema extraction from the input text can be run before entering the entity and relation extraction. This is controlled using the
schema
parameter:schema="EXTRACTED"
or (schema=None
, default value); The schema is automatically extracted from the input text once using LLM. This guiding schema is then used to structure entity and relation extraction for all chunks. This guarantees all chunks have the same guiding schema. (See Automatic Schema Extraction)schema="FREE"
or empty schema ({"node_types": ()}
) : No schema extraction is performed. Entity and relation extraction proceed without a predefined or derived schema, resulting in unguided entity and relation extraction. Use this to bypass automatic schema extraction.- Any other
schema
values are parsed into aGraphSchema
object that is used to guide the LLM in the extractor and clean the graph in the pruner.
GraphRAG: Ability to return a user-defined message if context is empty in GraphRAG
- In a GraphRAG pipeline, if the context returned by the retriever was empty, it is now possible to stop the pipeline and return a fallback response.
Misc
- Added support for Python 3.13
- Added the option to change the DB with retrieve_vector_index_info and retrieve_fulltext_index_info
- Added the ability to store messages in a different database in Neo4jMessageHistory
- Added createdAt property to Neo4jMessageHistory nodes
Fixed in 1.8.0
- Fixed a bug where
spacy
andrapidfuzz
needed to be installed even if not using the relevant entity resolvers. - Fixed
RunResult
model so that the results of each component in a pipeline are logged properly. - Fixed a bug where
VertexAILLM.invoke_with_tools
(andainvoke_with_tools
) would fail with multiple tools
Changed in 1.8.0
Strict mode in KG Builder pipeline (BREAKING CHANGE - EXPERIMENTAL NAMESPACE)
enforce_schema=”STRICT” | “None”
has been removed from SimpleKGPipeline
and config file. Schema enforcement is now based on schema definition. See "New in 1.8.0" above.
Removed SchemaConfig in favor of a new GraphSchema type (BREAKING CHANGE - EXPERIMENTAL NAMESPACE)
This is largely an internal change. However, you may be affected if you have implemented your own SchemaBuilder or if you are using its return value in another custom component (e.g. an entity/relation extractor).
BEFORE:
all_entities = list(schema_config.entities.values()) # list[dict]
person_entity = schema_config.entities["Person"] # dict
friendship_relationship = schema_config.relations["FRIENDSHIP"]
NOW:
all_entities = graph_schema.node_types # list[NodeType]
person_entity = graph_schema.node_type_from_label("Person") # NodeType object
friendship_relationship = graph_schema.relationship_type_from_label("FRIENDSHIP")
Introduce a new schema parameter in SimpleKGPipeline
Note: previous syntax with ‘entities’, ‘relations’ and ‘potential_schema’ still works… But it is deprecated and will be removed soon!
BEFORE:
kg_builder = SimpleKGPipeline(
# ...
entities=node_types,
relations=relationship_types,
potential_schema=patterns,
# ...
)
NOW:
kg_builder = SimpleKGPipeline(
# ...
schema={
"node_types": node_types,
"relationship_types": relationship_types,
"patterns": patterns,
},
# ...
)
Definition for node_types
, relationship_types
and patterns
is unchanged compared to the previous entities
, relations
and potential_schema
respectively.
Node properties in KG Builder
- Nodes created during the KG construction pipeline do not have an id property anymore.
- Similarly the
chunk_index
property is removed from all entity nodes (users can use the FROM_CHUNK relationship).
New Contributors
- @msenechal made their first contribution in #349
Neo4j GraphRAG Package for Python 1.7.0
New in 1.7.0
Full Changelog: 1.6.1...1.7.0
LLMInterface
- Added tool calling functionality to the LLM base class with OpenAI and VertexAI implementations, enabling structured parameter extraction and function calling.
Qdrant retriever
- Added support for multi-vector collection in Qdrant driver.
Entity resolution
- Added a new semantic match resolver to the KG Builder for entity resolution based on spaCy embeddings and cosine similarities so that nodes with similar textual properties get merged.
- Added a new fuzzy match resolver to the KG Builder for entity resolution based on RapiFuzz string fuzzy matching.
Pipeline
- Added a Pipeline.stream method to stream pipeline progress.
Fixed in 1.7.0
- Fixed a bug where the $nin operator for metadata pre-filtering in retrievers would create an invalid Cypher query.
Changed in 1.7.0
- Improved log output readability in Retrievers and GraphRAG and added embedded vector to retriever result metadata for debugging.
- Switched from pygraphviz to neo4j-viz
- Renders interactive graph now on HTML instead of PNG
- Removed get_pygraphviz_graph method
New Contributors
- @Dammerzone made their first contribution in #312
Neo4j GraphRAG Package for Python 1.6.1
Added in 1.6.1
- Added the
run_with_context
method to Component. This method includes acontext_
parameter, which provides information about the pipeline from which the component is executed (e.g., the run_id). It also enables the component to send events to the pipeline's callback function.
Fixed in 1.6.1
- Added
enforce_schema
parameter toSimpleKGPipeline
for optional schema enforcement.
Neo4j GraphRAG Package for Python 1.6.0
New in 1.6.0
https://github.com/neo4j/neo4j-graphrag-python/blob/main/CHANGELOG.md#160
Hybrid retrievers
- Add linear hybrid search ranker to give more weight to either the full text or the vector score.
- Raise SearchQueryParseError when HybridRetriever and HybridCypherRetriever encounters invalid Lucene string
KG Builder pipeline
- Add optional schema enforcement for KG builder as a validation layer after entity and relation extraction. If strict mode is enabled, properties, nodes and relationships not declared in the schema will be dropped from the LLM output.
Changed in 1.6.0
Dependencies
- Update dependencies in pyproject.toml (pypdf, anthropic, cohere)
Fixed in 1.6.0
- Config loading after module reload (for use in Jupyter notebooks)
- Fallback to Qdrant point id if
external_id_property
is not found in the point's payload inQdrantNeo4jRetriever
New Contributors
- @AlbertDoesProgramming made their first contribution in #298
- @ClemDoum made their first contribution in #288
Neo4j GraphRAG Package for Python 1.5.0
https://github.com/neo4j/neo4j-graphrag-python/blob/main/CHANGELOG.md#150
What's New in 1.5.0
- Added utility functions to retrieve metadata about existing vector and full-text indexes.
- Added support for the effective_search_ratio parameter in vector and hybrid searches, allowing finer control over query accuracy by adjusting the candidate pool size in similarity searches.
- Introduced the upsert_vectors utility function for batch upserting embeddings into vector indexes on both nodes and relationships.
- Introduced the extract_cypher function to improve the extraction of LLM-generated Cypher queries in Text2CypherRetriever.
- Added Neo4jMessageHistory for saving LLM chat message history to a Neo4j database.
- Added InMemoryMessageHistory for storing LLM chat message history in memory.
- Added example scripts and documentation for using the new message history classes.
- Updated LLM and GraphRAG classes to support message history functionality.
Changed in 1.5.0
- Added deprecation warnings to upsert_vector and upsert_vector_on_relationship, recommending migration to upsert_vectors.
- Added deprecation warnings to async_upsert_vector and async_upsert_vector_on_relationship, notifying developers of their planned removal in a future release.
- Added support for database, timeout, and sanitize arguments in schema retrieval functions. The sanitize option allows for the removal of large properties such as embeddings.
Fixed in 1.5.0
- Fixed an issue where a node alias was incorrectly hardcoded in the _handle_field_filter function.
Neo4j GraphRAG Package for Python 1.4.3
https://github.com/neo4j/neo4j-graphrag-python/blob/main/CHANGELOG.md#143
What's New in 1.4.3
- Added the ability to add event listener to get notifications about Pipeline progress.
- Added py.typed so that mypy knows to use type annotations from the
neo4j-graphrag
package.
Changed in 1.4.3
- Changed the default behaviour of
FixedSizeSplitter
to avoid words cut-off in the chunks whenever it is possible. Back to exact size splitter is possible usingapproximate=False
. - Updates tests to work with new Neo4j calendar versioning
neo4j_schema
is now used in custom prompt formatting inText2CypherRetriever
(if provided).
Fixed in 1.4.3
- Fixed a bug in the
AnthropicLLM
class preventing it from being used in GraphRAG pipeline. - Fixed a bug where the
extras
section of a config file was not resolved properly. - Fixed a bug where the LLM producing a valid JSON array was causing the
LLMEntityRelationExtractor
to fail. - Removed the
uuid
package from dependencies (not needed with Python 3).
New Contributors
- @NathalieCharbel made their first contribution in #242
- @koyonkym made their first contribution in #256
Neo4j GraphRAG Package for Python 1.4.2
Neo4j GraphRAG Package for Python 1.4.2
Fixed in 1.4.2
Ollama Embedding
Fixed a bug where OllamaEmbedding.embed_query
method was returning a list[list[float]]
instead of list[float]
.
Neo4j GraphRAG Package for Python 1.4.1
Neo4j GraphRAG Package for Python 1.4.1
Fixed in 1.4.1
Dependencies
PyYAML
dependency was missing and has been added.Weaviate
was unintentionally added as a mandatory dependency in previous version, this behavior has been reverted.PyPDF
andfsspec
are not optional anymore so thatSimpleKGPipeline
examples can run out of the box.
Neo4j GraphRAG Package for Python 1.4.0
What's New in 1.4.0
https://github.com/neo4j/neo4j-graphrag-python/blob/main/CHANGELOG.md#140
LLM Interface and GraphRAG
- Added ability to pass
system_instructions
to the LLM - Added ability to pass
message_history
to the LLM and GraphRAG - Enhanced
PromptTemplate
to add asystem_instruction
parameter.
Changed in 1.4.0
KG Construction Pipeline
- The
id_prefix
ofLexicalGraphConfig
is not used anymore and will be removed in a future version.
Fixed in 1.4.0
KG Construction Pipeline
- Fixed a bug where the chunk IDs were not unique and too many relationships were created in the lexical graph (between chunks and between entities and chunks). Now chunk IDs are UUIDs, truly unique, even for multiple runs on the same document or running the pipeline on multiple documents.
Neo4j GraphRAG Package for Python 1.3.0
https://github.com/neo4j/neo4j-graphrag-python/blob/main/CHANGELOG.md#130
What's New in 1.3.0
Entity and Relation Extraction Improvements
- Updated LLM prompt for Entity and Relation extraction to include stricter instructions for generating valid JSON.
- Integrated json-repair package to handle and repair invalid JSON generated by LLMs.
- Introduced InvalidJSONError exception for handling cases where JSON repair fails.
SimpleKGPipeline from config files
- Added the ability to create a Pipeline or SimpleKGPipeline from a config file. See the example.
Ollama support
- Added OllamaLLM and OllamaEmbeddings classes to make Ollama support more explicit.
- Implementations using the OpenAILLM and OpenAIEmbeddings classes will still work.
Changed in 1.3.0
- The default prompt in the
ERExtractionTemplate
prompt template has been updated to include more instructions about the expected return format.
Fixed in 1.3.0
Documentation
- Added schema functions to the documentation (
get_structured_schema
andget_schema
) - Improved documentation around the
Text2CypherTemplate
:- Class added to the API doc
- New example showcasing how to use a custom prompt