paint-brush
Texto Embeddings nisqamanta aswan karun: RAG Yanapakuykunapi Estructurado Willay Tapuykunapaq Ch'usaq kaqkunata allichayby@neo4j
151 ñawinchasqakuna

Texto Embeddings nisqamanta aswan karun: RAG Yanapakuykunapi Estructurado Willay Tapuykunapaq Ch'usaq kaqkunata allichay

by Neo4j17m2024/10/29
Read on Terminal Reader

Nishu unay; Ñawinchanapaq

Qillqa churaykuna mana ruwasqa qillqapaq RAG ruwanakunapi atiyniyuq kaptinkupas, ruwasqa tapuykunata pisiyanku. Yachaypa grafikunmi huk allichayta qun.
featured image - Texto Embeddings nisqamanta aswan karun: RAG Yanapakuykunapi Estructurado Willay Tapuykunapaq Ch'usaq kaqkunata allichay
Neo4j HackerNoon profile picture
0-item
1-item


Lliwmi qillqa churay modelokunata munanku, chaymanta allin razonwan: Mana estructurasqa qillqata codificaypi aswan allintam ruwanku, chaymi aswan facil semánticamente rikchakuq contenidota tariy. Mana musphaychu kanku aswan RAG ruwanakuna wasanpi ruwasqanku, aswanta kunan enfasis kaqwan codificación kaqpi chaymanta documentokunamanta chaymanta wak qillqa yanapakuykunamanta tupaq willayta kutichiypi. Ichaqa, kanmi sut'i ejemplokuna tapukuykunamanta huk tapukunman maypi qillqa churay enfoque RAG ruwanakunaman pisi urman chaymanta pantasqa willayta qun.


Nisqanchis hina, qillqa churaykunaqa ancha allinmi mana ruwasqa qillqakunata codificaypi. Huknin kaqpi, mana chayhina hatunchu kanku ruwasqa willaywan chaymanta ruwanakunawan ruwaypi kayhina filtración , t'aqay , utaq huñusqakuna . Piensariy kayna tapukuypi:


¿Ima peliculataq 2024 watapi aswan allin chaninchasqa lluqsirqa?


Kay tapuyta kutichinapaq, ñawpaqta lluqsichiy watamanhina filtrananchik tiyan, chaymantataq calificacionmanhina t'aqananchik tiyan. Qhawasaqku imayna huk ingenuo ruway qillqa churaykunawan ruwan chaymanta chaymanta rikuchisunchik imayna chayhina tapuykunata ruwayta. Kay blog qillqa rikuchin, mayk'aq ruwasqa willay ruwaykunawan ruwanki kayhina filtración, t'aqay utaq huñuy, wak yanapakuykunata llamk'achinayki tiyan mayqinkunachus estructurata qunku kayhina yachay graficokuna.


Chay codigoqa GitHub nisqapim kachkan.

Pachamamapa churakuynin

Kay blog qillqapaq, Neo4j Sandbox kaqpi yuyaychaykuna proyectota llamk'achisaqku. Yuyaychaykuna ruwayqa MovieLens willay huñuta llamk'achin , mayqinchus peliculakuna, ruwaqkuna, chaninchaykuna chaymanta aswan willakuyniyuq.


Esquema gráfico de recomendaciones nisqa willakuypa waqaychanan.


Kay qatiq codigo huk LangChain wrapper instancianqa Neo4j Willaypa Wasinwan tinkinapaq:


 os.environ["NEO4J_URI"] = "bolt://44.204.178.84:7687" os.environ["NEO4J_USERNAME"] = "neo4j" os.environ["NEO4J_PASSWORD"] = "minimums-triangle-saving" graph = Neo4jGraph(refresh_schema=False)


Chaymanta, huk OpenAI API llaveta mañakunki chaymanta kay qatiq codigopi pasanki:


 os.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")


Willay waqaychanapiqa 10.000 peliculakunam kachkan, ichaqa qillqakuna churasqakunaqa manaraqmi waqaychasqachu. Llapankupaq mana churasqakunata yupanapaq, 1.000 aswan allin chaninchasqa peliculakunata huk iskay kaq etiquetawan etiquetasaqku Target sutiyuq :


 graph.query(""" MATCH (m:Movie) WHERE m.imdbRating IS NOT NULL WITH m ORDER BY m.imdbRating DESC LIMIT 1000 SET m:Target """)

Texto churasqakunata yupay hinaspa waqaychay

Imakunata churanapaq tanteayqa ancha allinmi. Watamanhina filtracionta chaymanta calificacionmanhina t'aqayta rikuchisqaykurayku, mana chaninchu kanman chay detalles churasqa qillqamanta qarquyqa. Chayraykum akllarqani sapa peliculapa lluqsinan watata, calificacionninta, titulonta hinaspa descripcionninta hapinaypaq.


Kaypi huk rikch'anachiy qillqamanta churasaqku The Wolf of Wall Street peliculapaq:


 plot: Based on the true story of Jordan Belfort, from his rise to a wealthy stock-broker living the high life to his fall involving crime, corruption and the federal government. title: Wolf of Wall Street, The year: 2013 imdbRating: 8.2


Ichapas niwaq kayqa mana allin hamutaychu estructurasqa willayta churanapaq, chaymanta mana discutiymanchu mana aswan allin ruwayta yachasqayrayku. Ichapas llave-valor nisqa kaqkunamantaqa, qillqaman utaq imamanpas tikrananchik. Willaway sichus wakin yuyayniykikuna kanman imakuna aswan allinta llamk’anman chaymanta.


LangChain kaqpi Neo4j Vector objeto huk allin ñanniyuq from_existing_graphmaypi mayqin qillqa propiedades codificasqa kananku tiyan akllayta atikunki:


 embedding = OpenAIEmbeddings(model="text-embedding-3-small") neo4j_vector = Neo4jVector.from_existing_graph( embedding=embedding, index_name="movies", node_label="Target", text_node_properties=["plot", "title", "year", "imdbRating"], embedding_node_property="embedding", )


Kay rikch'anapi, OpenAI kaqpa qillqa-ch'usaqyachiy-3-huch'uy ruwayninta llamk'achiyku churanapaq miraypaq. Neo4jVector objetota qallariyku from_existing_graph ruwayta llamk'achispa. Node_label nisqa tupuqa codificasqa kanapaq nodukunatam filtran, específicamente Target nisqa sutichasqakunata. text_node_properties tupuqa nodu propiedades nisqakunatam riqsichin, chaypiqa plot , title , wata , imdbRating nisqapas. Tukuchanapaq, embedding_node_property maypi paqarichisqa churasqakuna waqaychasqa kanqa chayta riqsichin, embedding hina sutichasqa.

El Enfoque Ingenuo nisqa

Qallarisun, huk peliculata tariyta munaspa, chaypiqa tramaman hina otaq descripcionninman hina:


 pretty_print( neo4j_vector.similarity_search( "What is a movie where a little boy meets his hero?" ) )


Tukusqakuna:


 plot: A young boy befriends a giant robot from outer space that a paranoid government agent wants to destroy. title: Iron Giant, The year: 1999 imdbRating: 8.0 plot: After the death of a friend, a writer recounts a boyhood journey to find the body of a missing boy. title: Stand by Me year: 1986 imdbRating: 8.1 plot: A young, naive boy sets out alone on the road to find his wayward mother. Soon he finds an unlikely protector in a crotchety man and the two have a series of unexpected adventures along the way. title: Kikujiro (Kikujirô no natsu) year: 1999 imdbRating: 7.9 plot: While home sick in bed, a young boy's grandfather reads him a story called The Princess Bride. title: Princess Bride, The year: 1987 imdbRating: 8.1


Chay ruwasqakunaqa llapanpiqa allin takyasqa hinam. Sapa kutim huk uchuy warmacha involucrasqa kachkan, ichaqa manam segurochu kani sichus sapa kuti heroenwan tupasqanmanta. Chaymanta yapamanta, willay huñupiqa 1.000 peliculakunalla kachkan, chayrayku akllanakuna huk chhika pisilla kanku.


Kunanqa huk tapuyta pruebasun, chaymi wakin sapsi filtracionta munan:


 pretty_print( neo4j_vector.similarity_search( "Which movies are from year 2016?" ) )


Tukusqakuna:


 plot: Six short stories that explore the extremities of human behavior involving people in distress. title: Wild Tales year: 2014 imdbRating: 8.1 plot: A young man who survives a disaster at sea is hurtled into an epic journey of adventure and discovery. While cast away, he forms an unexpected connection with another survivor: a fearsome Bengal tiger. title: Life of Pi year: 2012 imdbRating: 8.0 plot: Based on the true story of Jordan Belfort, from his rise to a wealthy stock-broker living the high life to his fall involving crime, corruption and the federal government. title: Wolf of Wall Street, The year: 2013 imdbRating: 8.2 plot: After young Riley is uprooted from her Midwest life and moved to San Francisco, her emotions - Joy, Fear, Anger, Disgust and Sadness - conflict on how best to navigate a new city, house, and school. title: Inside Out year: 2015 imdbRating: 8.3


Asikunapaq hinam, ichaqa manam huk peliculallapas 2016 watamanta akllasqachu karqa. Ichapas aswan allin ruwaykunata tarisunman hukniray qillqa wakichiywan codificaciónpaq. Ichaqa, qillqa churaykuna mana kaypi ruwanapaqchu kanku chaymanta huk sanu estructurasqa willay llamk'achiyta ruwachkayku maypi qillqakunata utaq, kay rikch'anapi, peliculakuna huk metadato propiedad kaqpi filtrayta necesitayku. Metadatos filtración nisqaqa allin takyasqa técnica nisqa sapa kuti llamk'achisqa RAG sistemakunap chiqan kayninta aswan allin kananpaq.


Qatiqnin tapuyta pruebasaqku huk chhika t'aqayta munan:


 pretty_print( neo4j_vector.similarity_search("Which movie has the highest imdb score?") )


Tukusqakuna:


 plot: A silent film production company and cast make a difficult transition to sound. title: Singin' in the Rain year: 1952 imdbRating: 8.3 plot: A film about the greatest pre-Woodstock rock music festival. title: Monterey Pop year: 1968 imdbRating: 8.1 plot: This movie documents the Apollo missions perhaps the most definitively of any movie under two hours. Al Reinert watched all the footage shot during the missions--over 6,000,000 feet of it, ... title: For All Mankind year: 1989 imdbRating: 8.2 plot: An unscrupulous movie producer uses an actress, a director and a writer to achieve success. title: Bad and the Beautiful, The year: 1952 imdbRating: 7.9


Sichus IMDb calificacionkunata riqsinki, yachanki achka peliculakuna 8.3 patamanta puntuacionniyuq kasqankuta. Aswan hatun chaninchasqa titulo base de datosniykupi chiqamanta huk serie — Band of Brothers — huk admirable 9.6 calificación kaqwan. Huk kutitawan, qillqa churaykuna mana allintachu ruwanku, ruwasqakuna t'aqaypi.


Chaninchasuntaqmi huk tapukuyta, chay tapukuyqa ima rikchaq huñunapaqpas necesitakunmi:


 pretty_print(neo4j_vector.similarity_search("How many movies are there?"))


Tukusqakuna:


 plot: Ten television drama films, each one based on one of the Ten Commandments. title: Decalogue, The (Dekalog) year: 1989 imdbRating: 9.2 plot: A documentary which challenges former Indonesian death-squad leaders to reenact their mass-killings in whichever cinematic genres they wish, including classic Hollywood crime scenarios and lavish musical numbers. title: Act of Killing, The year: 2012 imdbRating: 8.2 plot: A meek Hobbit and eight companions set out on a journey to destroy the One Ring and the Dark Lord Sauron. title: Lord of the Rings: The Fellowship of the Ring, The year: 2001 imdbRating: 8.8 plot: While Frodo and Sam edge closer to Mordor with the help of the shifty Gollum, the divided fellowship makes a stand against Sauron's new ally, Saruman, and his hordes of Isengard. title: Lord of the Rings: The Two Towers, The year: 2002 imdbRating: 8.7


Chay ruwasqakuna mana kaypi yanapakuqchu kanku imaraykuchus tawa peliculakuna aleatorias kutichisqa kayku. Yaqa mana atikunchu kay tawa peliculakuna random kaqmanta huk tukukuyta tariyta chaymanta kanku tukuyninpi 1.000 peliculakuna etiquetasqayku chaymanta kay ejemplopaq churasqayku.


Hinaptinqa, ¿imataq chay allichayqa? Chiqan: Tapuykuna ruwasqa ruwanakuna filtración, t'aqay chaymanta huñuy hina ruwasqa yanapakuykunata necesitanku ruwasqa willaykunawan llamk'anapaq.

Estructurado nisqa willakuykunapaq yanapakuykuna

Kunan pacha, yaqa llapan runakuna text2query enfoque kaqpi yuyaykunku, maypi huk LLM huk willaypa tiyapuynin tapuyta ruwan huk willaypa tiyapuyninwan tinkinapaq qusqa tapuypi chaymanta esquema kaqpi. Neo4j kaqpaq, kayqa text2cypher kaq, ichaqa text2sql kaqpas SQL willay tantanakunapaq kan. Ichaqa, ruwaypiqa mana confiablechu, manataqmi suficientechu robustochu producción utilizanapaq.


Cifra nisqa willakuy miray chaninchay. Cypher chaninchaymanta blog qillqasqaymanta hurqusqa .


Técnicakunata llamk'achiy atikunki cadena de pensamiento, pisi disparo ejemplokuna utaq allin afinación hina, ichaqa hatun chiqan kayta aypayqa yaqa mana atikuqmi kay etapapi. text2query ruwayqa allinta llamkan sasan tapuykunapaq chiqan willaypa tiyapuynin esquemakunapi, ichaqa chay mana chiqachu ruruchina muyuriqkunamanta. Kayta allichanapaq, willaypa tiyapuynin tapuykunata ruwaypa complejidadninta huk LLM kaqmanta karunchakuyku chaymanta huk código sasachakuy hina qhawayku maypi willaypa tiyapuynin tapuykunata determinísticamente ruway yaykuykunapi ruwasqayku. Ventajaqa ancha allinchasqa sinchi kayninmi, ichaqa pisi flexibilidad nisqapa chaninwanmi hamun. Aswan allinmi RAG ruwanapa alcancenta pisiyachiy chaymanta chay tapuykunata chiqamanta kutichiy, tukuy imata kutichiyta munaspa ichaqa mana chiqan ruwaymanta.


Willaypa tiyapuynin tapuykunata ruwachkasqaykurayku — kayhinapi, Cypher willakuykunata — ruwana yaykuykunapi hapipakuspa, LLMkunap yanapakuy atiyninkunata aprovechayta atiyku. Kay ruwaypi, LLM hunt'achin tupaq parámetros kaqmanta ruwaqpa yaykuyninpi, chaymanta ruwana necesario willayta kutichiyta ruwan. Kay rikuchiypaq, ñawpaqta iskay yanapakuykunata ruwasaqku: huknin peliculakuna yupanapaq huknintaq listapaq, chaymanta huk LLM agente LangGraph kaqwan ruwasaqku.

Películakunata Yupanapaq yanapakuy

Qallariyku huk yanapakuyta peliculakuna yupanapaq ñawpaqmanta riqsisqa filtrokunapi hapipakuspa. Ñawpaqtaqa, ima chay filtrokuna kasqanmanta riqsichinanchik tiyan chaymanta huk LLM kaqman willananchik tiyan mayk'aq chaymanta imayna llamk'achiyta:


 class MovieCountInput(BaseModel): min_year: Optional[int] = Field( description="Minimum release year of the movies" ) max_year: Optional[int] = Field( description="Maximum release year of the movies" ) min_rating: Optional[float] = Field(description="Minimum imdb rating") grouping_key: Optional[str] = Field( description="The key to group by the aggregation", enum=["year"] )


LangChain achka ñankunata qun ruwanakuna yaykuykunata riqsichinapaq, ichaqa Pydantic ruwayta aswan allinta qhawani. Kay rikch'anapi, kimsa filtrokunayuq kayku pelicula ruwaykunata allinchaypaq: min_year, max_year chaymanta min_rating. Kay filtrokuna ruwasqa willaykunapi sayasqa kanku chaymanta munasqa kanku, imaynachus llamk'achiq mayqintapas, llapanta utaq mana mayqintapas churayta akllanman. Chaymanta, huk grouping_key yaykuy riqsichisqayku chaymanta ruwanaman willan sichus yupayta huk sapanchasqa kaqninwan huñunanta. Kayhina kaptinqa, sapallan yanapasqa huñuyqa wataman hinam, enumsection nisqapi nisqanman hina.


Kunanqa chiqap ruwayta riqsichisun:


 @tool("movie-count", args_schema=MovieCountInput) def movie_count( min_year: Optional[int], max_year: Optional[int], min_rating: Optional[float], grouping_key: Optional[str], ) -> List[Dict]: """Calculate the count of movies based on particular filters""" filters = [ ("t.year >= $min_year", min_year), ("t.year <= $max_year", max_year), ("t.imdbRating >= $min_rating", min_rating), ] # Create the parameters dynamically from function inputs params = { extract_param_name(condition): value for condition, value in filters if value is not None } where_clause = " AND ".join( [condition for condition, value in filters if value is not None] ) cypher_statement = "MATCH (t:Target) " if where_clause: cypher_statement += f"WHERE {where_clause} " return_clause = ( f"t.`{grouping_key}`, count(t) AS movie_count" if grouping_key else "count(t) AS movie_count" ) cypher_statement += f"RETURN {return_clause}" print(cypher_statement) # Debugging output return graph.query(cypher_statement, params=params)


Movie_count ruwana huk Cypher tapuyta ruwan peliculakuna yupanapaq akllana filtrokuna chaymanta huñusqa llave kaqpi. Qallarin huk lista filtrokuna definispa tupaq chanikuna argumentokuna hina qusqa. Filtrokuna WHERE cláusula dinamicamente ruwanapaq llamk'achkanku, mayqinchus Cypher willakuypi nisqa filtración condicionkunata ruwanapaq, chaymanta chay condicionkunalla maypi chanikuna mana Mana imapaschu.


Chaymanta Cypher tapuypa RETURN cláusula ruwasqa, qusqa grouping_key kaqwan huñusqa utaq llapan peliculakuna yupaylla. Tukuyninpiqa, ruwayqa tapuyta ruwan, chaymantataq ruwasqakunata kutichin.


Ruwayqa aswan argumentokunawan chaymanta aswan involucrado lógica kaqwan mast'arisqa kanman necesitasqanmanhina, ichaqa importante kanman sut'i kananpaq qhaway chaymanta huk LLM allinta chaymanta chiqan waqyayta atin.

Películakunata Listanapaq yanapakuy

Yapamanta, ruwanapa argumentonkunata riqsichispa qallarinanchik tiyan:


 class MovieListInput(BaseModel): sort_by: str = Field( description="How to sort movies, can be one of either latest, rating", enum=["latest", "rating"], ) k: Optional[int] = Field(description="Number of movies to return") description: Optional[str] = Field(description="Description of the movies") min_year: Optional[int] = Field( description="Minimum release year of the movies" ) max_year: Optional[int] = Field( description="Maximum release year of the movies" ) min_rating: Optional[float] = Field(description="Minimum imdb rating")


Kikin kimsa filtrokuna pelicula yupay ruwaypi hina waqaychayku ichaqa willakuy argumentota yapayku. Kay argumentoqa peliculakunata maskayta hinaspa listayta saqiwanchik trama nisqanman hina vector rikchakuy maskaywan. Estructurasqa yanapakuykunata chaymanta filtrokunata llamk'achkasqaykuraykulla mana niyta munanchu mana qillqa churayta chaymanta vector maskana ñankunata churayta atiykuchu. Mana llapa peliculakunata kutichiyta munasqaykurayku aswan achka kutipi, huk akllana k yaykuyta huk ñawpaqmanta chaniyuqwan churayku. Chaymantapas, listapaq, peliculakunata ordenayta munayku aswan tupaqninllata kutichinaykupaq. Kayhina kaqtinqa, chaykunataqa calificacionmanhina utaq lluqsichiy watamanhina t'aqayta atiykuman.


Ruwayta hunt'achisun:


 @tool("movie-list", args_schema=MovieListInput) def movie_list( sort_by: str = "rating", k : int = 4, description: Optional[str] = None, min_year: Optional[int] = None, max_year: Optional[int] = None, min_rating: Optional[float] = None, ) -> List[Dict]: """List movies based on particular filters""" # Handle vector-only search when no prefiltering is applied if description and not min_year and not max_year and not min_rating: return neo4j_vector.similarity_search(description, k=k) filters = [ ("t.year >= $min_year", min_year), ("t.year <= $max_year", max_year), ("t.imdbRating >= $min_rating", min_rating), ] # Create parameters dynamically from function arguments params = { key.split("$")[1]: value for key, value in filters if value is not None } where_clause = " AND ".join( [condition for condition, value in filters if value is not None] ) cypher_statement = "MATCH (t:Target) " if where_clause: cypher_statement += f"WHERE {where_clause} " # Add the return clause with sorting cypher_statement += " RETURN t.title AS title, t.year AS year, t.imdbRating AS rating ORDER BY " # Handle sorting logic based on description or other criteria if description: cypher_statement += ( "vector.similarity.cosine(t.embedding, $embedding) DESC " ) params["embedding"] = embedding.embed_query(description) elif sort_by == "rating": cypher_statement += "t.imdbRating DESC " else: # sort by latest year cypher_statement += "t.year DESC " cypher_statement += " LIMIT toInteger($limit)" params["limit"] = k or 4 print(cypher_statement) # Debugging output data = graph.query(cypher_statement, params=params) return data


Kay ruwana huk lista peliculakuna achka akllana filtrokuna kaqpi kutichin: willakuy, wata puriy, aswan pisi chaninchay chaymanta t'aqay munasqakuna. Sichus huk willakuylla qusqa mana huk filtrokunawan, huk vector índice rikch'akuy maskana ruwan tupaq peliculakuna tarinapaq. Yapa filtrokuna churasqa kaqtin, ruwana huk Cypher tapuyta ruwan peliculakuna tupachinanpaq criteriokuna kaqpi, ahinataq lluqsichiy wata chaymanta IMDb chaninchay, huk akllana willakuypi ruwasqa rikch'akuywan tinkin. Chaymanta ruwasqakuna t'aqasqa kanku icha rikch'akuy puntuación kaqwan, IMDb chaninchaywan utaq watawan, chaymanta k peliculakunallapi limitasqa.

Tukuy chayta Huñuspa LangGraph Agente hina

Huk chiqan ReAct agente LangGraph kaqwan ruwasaqku.


LangGraph agente ruway.


Agente huk LLM chaymanta herramientakuna llamkanamanta ruwasqa kachkan. Agentewan tinkisqaykumanhina, ñawpaqta LLM kaqman waqyasaqku sichus yanapakuykunata llamk'achinayku tiyan chayta tanteanaykupaq. Chaymantaqa huk llañuta purichisunchik:


  1. Sichus agente huk ruwayta ruwanaypaq nirqa (icha, yanapakuy waqyay), yanapakuykunata purichisaqku chaymanta ruwasqakunata agenteman kutichisaqku.
  2. Sichus agente mana mañarqachu yanapakuykunata purichinanpaq, tukusaqku (ruraqman kutichiy).


Codigo ruwayqa imayna chiqanmi chayman hina. Ñawpaqtaqa LLM nisqamanmi yanapakuykunata watayku hinaspa yanapaq llamkayta riqsichiyku:


 llm = ChatOpenAI(model='gpt-4-turbo') tools = [movie_count, movie_list] llm_with_tools = llm.bind_tools(tools) # System message sys_msg = SystemMessage(content="You are a helpful assistant tasked with finding and explaining relevant information about movies.") # Node def assistant(state: MessagesState): return {"messages": [llm_with_tools.invoke([sys_msg] + state["messages"])]}


Chaymantaqa LangGraph flujo nisqatam riqsichinchik:


 # Graph builder = StateGraph(MessagesState) # Define nodes: these do the work builder.add_node("assistant", assistant) builder.add_node("tools", ToolNode(tools)) # Define edges: these determine how the control flow moves builder.add_edge(START, "assistant") builder.add_conditional_edges( "assistant", # If the latest message (result) from assistant is a tool call -> tools_condition routes to tools # If the latest message (result) from assistant is a not a tool call -> tools_condition routes to END tools_condition, ) builder.add_edge("tools", "assistant") react_graph = builder.compile()


LangGraph nisqapi iskay nodukunata riqsichiyku, chaymantataq huk kantu condicional nisqawan tinkuyku. Sichus huk yanapakuy waqyasqa kanman chayqa, chay flujoqa herramientakunamanmi dirigikun; mana hina kaqtinqa, chay ruwasqakuna kutichisqa kanku ruwaqman.


Kunanqa agentenchista pruebasun:


 messages = [ HumanMessage( content="What are the some movies about a girl meeting her hero?" ) ] messages = react_graph.invoke({"messages": messages}) for m in messages["messages"]: m.pretty_print()


Tukusqakuna:


Tukusqakuna


Ñawpaq llamk'aypi, agente pelicula-lista yanapakuyta tupaq descripciónparámetro kaqwan llamk'ayta akllan. Mana sut'ichu imaraykutaq 5 kvalue nisqa akllan, ichaqa chay yupayta favoreceq hinam. Herramientaqa pichqa aswan allin peliculakunata kutichin tramaman hina, chaymanta LLM tukukuypi ruwaqpaqlla resumenpi ruwan.


Sichus ChatGPT tapusunman imaraykutaq k valor 5 gustan, kay kutichiyta tarinchik.



Chaymanta, huk pisi aswan sasachakuyniyuq tapuyta ruwasun, chaypaqqa metadatukuna filtrayta munan:


 messages = [ HumanMessage( content="What are the movies from the 90s about a girl meeting her hero?" ) ] messages = react_graph.invoke({"messages": messages}) for m in messages["messages"]: m.pretty_print()


Tukusqakuna:


Tukusqakuna


Kay kutipiqa, 1990 watakunamantalla peliculakunata filtranankupaqmi huk argumentokunata servichikurqaku. Kay ejemploqa huk típico ejemplo kanman metadatos filtración kaqmanta ñawpaq filtración ruwayta llamk'achispa. Cypher nisqa paqarichisqa willakuyqa ñawpaqta peliculakunata pisiyachin, lluqsiynin watapi filtraspa. Qatiqnin rakipi, Cypher nisqa willakuyqa qillqa churaykunata chaymanta vector rikch'akuy maskanawan llamk'achin, huk sipascha heroenwan tupasqanmanta peliculakunata tarinanpaq.


Imaymana condicionkunaman hina peliculakunata yupanapaq kallpachakusun:


 messages = [ HumanMessage( content="How many movies are from the 90s have the rating higher than 9.1?" ) ] messages = react_graph.invoke({"messages": messages}) for m in messages["messages"]: m.pretty_print()


Tukusqakuna:


Tukusqakuna


Yupanapaq huk sapaqchasqa yanapakuywan, complejidadqa LLM kaqmanta yanapakuyman tikrakun, LLM kaqmanta saqispa chaymanta tupaq ruwana parámetros hunt'achiyllamanta. Kay ruwanakuna rakiyqa sistemata aswan allin ruwaq chaymanta kallpasapa ruwan chaymanta LLM yaykuypa sasachakuyninta pisiyachin.


Agente achka yanapakuykunata qatiqninpi utaq paralelopi waqyayta atisqanrayku, aswan sasachakuyniyuq kaqwan pruebasun:


 messages = [ HumanMessage( content="How many were movies released per year made after the highest rated movie?" ) ] messages = react_graph.invoke({"messages": messages}) for m in messages["messages"]: m.pretty_print()


Tukusqakuna


Tukusqakuna


Nisqanchis hina, agenteqa askha yanapakuykunata waqyayta atinmi llapa necesario willakuykunata huñunanpaq tapuyta kutichinanpaq. Kay ejemplopiqa qallarikunmi aswan allin qhawarisqa peliculakunata listaspa, chhaynapi yachanapaq hayk’aqmi aswan allin qhawarisqa pelicula lloqsimurqan. Huk kuti chay willayta hap'ispa, pelicula yupay yanapakuyta waqyan huñunapaq hayk'a peliculakuna lluqsisqa chay nisqa watamanta, huk huñu llaveta tapuypi nisqa hina.

Pisiyachisqa

Qillqa churaykuna mana ruwasqa willayta maskanapaq ancha allin kaptinkupas, pisiyapunku mayk'aq ruwasqa llamkanakuna filtración , t'aqay , huñuy hina. Kay ruwanakuna estructurasqa willaykunapaq ruwasqa yanapakuykunata munanku, mayqinkunachus kay ruwanakuna ruwanapaq precisión chaymanta flexibilidad necesitasqankuta qunku. Llave apakuyqa sistemaykipi yanapakuykuna huñuta mast'ariyqa aswan hatun llamk'aq tapuykunata allichayta atikunki, ruwanakunayki aswan kallpasapa chaymanta versatil ruway. Estructurasqa willay enfoquekuna chaymanta mana estructurasqa qillqa maskana técnicas kaqwan tinkiyqa aswan chiqan chaymanta tupaq kutichiykunata quyta atin, qhipaman RAG ruwanakunapi user experienciata aswan allinchayta atin.


Sapa kuti hina, codigoqa GitHub nisqapim kachkan.


Kay temamanta astawan yachanaykipaq, NODES 2024 kaqpi 7 ñiqin inti raymi killapi ñuqaykuwan kuska, mana qullqiyuq virtual paqarichiqkuna hatun huñunakuyniykumanta yuyaysapa ruwanakuna, yachay graficokuna chaymanta AI kaqmanta. ¡Kunanpacha qillqakuy!