Close Menu
  • AI
  • Content Creation
  • Tech
  • Robotics
AI-trends.todayAI-trends.today
  • AI
  • Content Creation
  • Tech
  • Robotics
Trending
  • Perplexity Trains Its Pc Agent on Actual Errors With Trace-Guided Self-Distillation
  • Appeals Court docket Lets the Pentagon Designate Anthropic a Provide-Chain Threat
  • Aikido Safety Releases Altar-1: An Open-Weight Safety Mannequin Pruned From GLM-5.3 to 328 GB
  • Black Forest Labs Releases FLUX 3 Motion: A 7B Open-Weights World Motion Mannequin That Tops RoboLab-120
  • Fastino Releases GLiNER2.5-Resolve: A 340M Open-Weight Determination Mannequin That Runs on CPU
  • BottleCap AI Releases ThinkingCap-Qwen3.8-27B: 37.2% Fewer Considering Tokens at a 0.86pp Accuracy Price
  • What if I find an AI agent that is worth the risk?
  • Google’s Gemini Can Now Make Requires You on Pixel Telephones
AI-trends.todayAI-trends.today
Home»Tech»Create a reinforcement learning powered agent that learns to retrieve relevant long-term memories for accurate LLM question answering

Create a reinforcement learning powered agent that learns to retrieve relevant long-term memories for accurate LLM question answering

Tech By Gavin Wallace27/04/20263 Mins Read
Facebook Twitter LinkedIn Email
Samsung Researchers Introduced ANSE (Active Noise Selection for Generation): A
Samsung Researchers Introduced ANSE (Active Noise Selection for Generation): A
Share
Facebook Twitter LinkedIn Email
@dataclass
Class MemoryItem
 Memory_id:
 Topic:
 Entity:
 Slot: str
 Value: str
 Text


Def Build Memory Bank() -> List[MemoryItem]:
 Entities [
       {
           "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_templates = [
       "{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.",
   ]


   memory_bank = []
   memory_id = 0


 For item in Entities:
 Entity = Item["entity"]
 Topic = item["topic"]
 Slot value["facts"].items():
 Templates for the letter t:
               text = t.format(entity=entity, topic=topic, slot=slot, value=value)
               memory_bank.append(MemoryItem(
                   memory_id=memory_id,
                   topic=topic,
                   entity=entity,
                   slot=slot,
                   value=value,
                   text=text
               ))
               memory_id += 1


       for t in distractor_templates:
           text = t.format(entity=entity)
           memory_bank.append(MemoryItem(
               memory_id=memory_id,
               topic=topic,
               entity=entity,
               slot="distractor",
               value="n/a",
               text=text
           ))
           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.",
   ]


 Text in extra_noise
       memory_bank.append(MemoryItem(
           memory_id=memory_id,
           topic="noise",
           entity="none",
           slot="distractor",
           value="n/a",
           text=text
       ))
       memory_id += 1


 Memory_bank return


memory_bank = build_memory_bank()
memory_texts = [m.text for m in memory_bank]
memory_embeddings = embed_texts(memory_texts)


def build_queries(memory_bank: List[MemoryItem]) -> List[Dict[str, Any]]:
 Patterns = [
       "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}?",
   ]
   queries = []
   qid = 0
 For m, memory_bank
 If slot == "distractor":
 Continue reading
       q = random.choice(patterns).format(slot=m.slot.replace("_", " "), entity=m.entity)
       queries.append({
           "query_id": qid,
           "query": q,
           "entity": m.entity,
           "slot": m.slot,
           "gold_value": m.value,
           "gold_memory_id": m.memory_id,
           "gold_text": m.text,
           "topic": m.topic,
       })
       qid += 1
   random.shuffle(queries)
   return queries


queries = build_queries(memory_bank)
query_texts = [q["query"] for q in queries]
query_embeddings = embed_texts(query_texts)
ar learning van
Share. Facebook Twitter LinkedIn Email
Avatar
Gavin Wallace

Related Posts

Perplexity Trains Its Pc Agent on Actual Errors With Trace-Guided Self-Distillation

25/09/2026

Aikido Safety Releases Altar-1: An Open-Weight Safety Mannequin Pruned From GLM-5.3 to 328 GB

25/09/2026

Black Forest Labs Releases FLUX 3 Motion: A 7B Open-Weights World Motion Mannequin That Tops RoboLab-120

25/09/2026

Fastino Releases GLiNER2.5-Resolve: A 340M Open-Weight Determination Mannequin That Runs on CPU

25/09/2026
Top News

Salesforce’s party was ruined by the AI Slowdown debate

Napster Is Again, and It Desires to Digitally Clone Academics

It’s all over with the fake AI about the Iran war.

Overlook the AI Slowdown—the Vulnerability Explosion Is Already Taking place

Sam Altman’s House allegedly attacked by Molotov Cocktail thrower

Load More
AI-Trends.Today

Your daily source of AI news and trends. Stay up to date with everything AI and automation!

X (Twitter) Instagram
Top Insights

Google’s Gemini Can Now Make Requires You on Pixel Telephones

24/09/2026

Perplexity Releases Mac Hybrid Computing: Cloud Agents orchestrate to a locally-based model and a gated device

02/09/2026
Latest News

Perplexity Trains Its Pc Agent on Actual Errors With Trace-Guided Self-Distillation

25/09/2026

Appeals Court docket Lets the Pentagon Designate Anthropic a Provide-Chain Threat

25/09/2026
X (Twitter) Instagram
  • Privacy Policy
  • Contact Us
  • Terms and Conditions
© 2026 AI-Trends.Today

Type above and press Enter to search. Press Esc to cancel.