AllTopicsTodayAllTopicsToday
Notification
Font ResizerAa
  • Home
  • Tech
  • Investing & Finance
  • AI
  • Entertainment
  • Wellness
  • Gaming
  • Movies
Reading: Build a Reinforcement Learning Powered Agent that Learns to Retrieve Relevant Long-Term Memories for Accurate LLM Question Answering
Share
Font ResizerAa
AllTopicsTodayAllTopicsToday
  • Home
  • Blog
  • About Us
  • Contact
Search
  • Home
  • Tech
  • Investing & Finance
  • AI
  • Entertainment
  • Wellness
  • Gaming
  • Movies
Have an existing account? Sign In
Follow US
©AllTopicsToday 2026. All Rights Reserved.
AllTopicsToday > Blog > AI > Build a Reinforcement Learning Powered Agent that Learns to Retrieve Relevant Long-Term Memories for Accurate LLM Question Answering
AI

Build a Reinforcement Learning Powered Agent that Learns to Retrieve Relevant Long-Term Memories for Accurate LLM Question Answering

AllTopicsToday
Last updated: April 27, 2026 7:01 pm
AllTopicsToday
Published: April 27, 2026
Share
SHARE
@dataclass class MemoryItem:memory_id:int subject:str entity:str slot:str worth:str textual content:str def build_memory_bank() -> checklist[MemoryItem]: entity = [
{
“entity”: “Astra”,
“topic”: “robotics”,
“facts”: {
“battery”: “18 hours”,
“sensor”: “LiDAR”,
“country”: “Japan”,
“release_year”: “2023”,
“specialty”: “warehouse navigation”,
},
},
{
“entity”: “Orion”,
“topic”: “astronomy”,
“facts”: {
“telescope”: “infrared array”,
“country”: “Chile”,
“discovery_year”: “2019”,
“target”: “exoplanet atmospheres”,
“aperture”: “8 meters”,
},
},
{
“entity”: “Vita”,
“topic”: “biomedicine”,
“facts”: {
“compound”: “VX-17”,
“trial_phase”: “Phase II”,
“country”: “Canada”,
“target”: “inflammatory markers”,
“delivery”: “oral capsule”,
},
},
{
“entity”: “Nimbus”,
“topic”: “climate”,
“facts”: {
“satellite”: “polar orbiter”,
“country”: “Norway”,
“launch_year”: “2022”,
“instrument”: “microwave radiometer”,
“mission”: “sea ice monitoring”,
},
},
{
“entity”: “Atlas”,
“topic”: “logistics”,
“facts”: {
“fleet_size”: “240 trucks”,
“hub”: “Muscat”,
“software”: “predictive routing”,
“fuel_policy”: “hybrid-first”,
“region”: “GCC”,
},
},
{
“entity”: “Lumos”,
“topic”: “materials”,
“facts”: {
“alloy”: “Ti-6Al-4V”,
“process”: “laser sintering”,
“density”: “4.43 g/cm3”,
“country”: “Germany”,
“use_case”: “aerospace brackets”,
},
},
{
“entity”: “Cedar”,
“topic”: “agriculture”,
“facts”: {
“crop”: “wheat”,
“irrigation”: “drip control”,
“country”: “India”,
“yield_gain”: “12 percent”,
“soil_sensor”: “capacitive probe”,
},
},
{
“entity”: “Pulse”,
“topic”: “healthcare”,
“facts”: {
“device”: “ECG patch”,
“battery”: “7 days”,
“country”: “USA”,
“connectivity”: “Bluetooth Low Energy”,
“use_case”: “arrhythmia screening”,
},
},
]

phrasing_templates = [
“{entity} in {topic} uses {value} for {slot}.”,
“The {slot} associated with {entity} is {value}.”,
“{entity} has {slot}: {value}.”,
“For {entity}, the recorded {slot} is {value}.”,
“Reference note: {entity} -> {slot} = {value}.”,
]

distractor_template = [
“{entity} was discussed in a briefing about cross-domain innovation.”,
“{entity} has been compared with several other projects in recent reports.”,
“A summary note mentions {entity} among notable initiatives.”,
“{entity} appears in a high-level update without technical details.”,
“Stakeholders reviewed {entity} in a strategic planning session.”,
]

reminiscence financial institution = []
For gadgets inside an entity, memory_id = 0: entity = merchandise[“entity”]
subject = merchandise[“topic”]
For slots, the worth of the merchandise[“facts”].gadgets(): for t in phrasing_templates: textual content = t.format(entity=entity, subject=subject, slot=slot, worth=worth)memory_bank.append(MemoryItem(memory_id=memory_id, subject=subject,entity=entity, slot=slot, worth=worth, textual content=textual content ))memory_id += 1 for t in destroyr_templates: textual content = t.format (entity=entity) memory_bank.append (MemoryItem (memory_id=memory_id, subject=subject, entity=entity, slot=”distractor”, worth=”n/a”, textual content=textual content )) memory_id += 1 extra_noise = [
“General note: system maintenance occurred on Tuesday.”,
“A committee discussed budget timelines and operational readiness.”,
“The archive includes summaries of projects across multiple departments.”,
“No relevant technical value is stated in this memory.”,
“A status update mentioned partnerships and future opportunities.”,
“An unrelated note references shipping delays and staffing changes.”,
“Background memo: the team reviewed dashboards and reporting cadence.”,
“This memory contains no answer-bearing facts.”,
]

For textual content in extra_noise:memory_bank.append(MemoryItem(memory_id=memory_id, subject=”noise”,entity=”none”, slot=”distractor”, worth=”n/a”, textual content=textual content ))memory_id += 1 return memory_bankmemory_bank = build_memory_bank()memory_texts = [m.text for m in memory_bank]
Memory_embeddings = embed_texts(memory_texts) def build_queries(memory_bank: Checklist)[MemoryItem]) -> checklist[Dict[str, Any]]: sample = [
“What is the {slot} of {entity}?”,
“Which {slot} does {entity} have?”,
“Tell me the {slot} for {entity}.”,
“Can you recall the {slot} associated with {entity}?”,
“What was recorded as the {slot} of {entity}?”,
]
question = []
qid of m in reminiscence financial institution = 0: if m.slot == “distractor”: proceed q = random.selection(patterns).format(slot=m.slot.change(“_”, ” “),entity=m.entity) queries.append({ “query_id”: qid, “question”: q, “entity”: m.entity, “slot”: m.slot, “gold_value”: m.worth, “gold_memory_id”: m.memory_id, “gold_text”: m.textual content, “subject”: m.subject, }) qid += 1 random.shuffle(queries) return queries queries = build_queries(memory_bank) query_texts = [q[“query”] for q within the question]query_embeddings = embed_texts(query_texts)

Best GPUs for GPT-OSS Models (2025)
Can AI Save Indian Farmers?
Trump is weighing options against Iran: Reports
How AI Knows a Stock Will Rise, and How You Can Too
Who’s to Blame When AI Goes Rogue? The UN’s Quiet Warning That Got Very Loud
Share This Article
Facebook Email Print
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow US

Find US on Social Medias
FacebookLike
XFollow
YoutubeSubscribe
TelegramFollow

Weekly Newsletter

Subscribe to our newsletter to get our newest articles instantly!
Popular News
Val kilmers digital resurrection is jolting the entertainment industry and raising some uncomfortabl.jpeg
AI

Val Kilmer’s digital resurrection is jolting the entertainment industry, and raising some uncomfortable dilemmas

AllTopicsToday
AllTopicsToday
March 23, 2026
Should You Buy an iPhone 16 or iPhone 17? Here’s How They Compare
Four-Day Workweeks and Robot Taxes? OpenAI’s Radical Vision for the AI Future Is Turning Heads
Terence Stamp’s Posthumous Return in Priscilla Queen of the Desert 2
Hands-On Review of Google’s High-Speed AI
- Advertisement -
Ad space (1)

Categories

  • Tech
  • Investing & Finance
  • AI
  • Entertainment
  • Wellness
  • Gaming
  • Movies

About US

We believe in the power of information to empower decisions, fuel curiosity, and spark innovation.
Quick Links
  • Home
  • Blog
  • About Us
  • Contact
Important Links
  • About Us
  • Privacy Policy
  • Terms and Conditions
  • Disclaimer
  • Contact

Subscribe US

Subscribe to our newsletter to get our newest articles instantly!

©AllTopicsToday 2026. All Rights Reserved.
1 2
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?