1 of 31

Agentic Semantic Search using Small Language Models (SLM)

​

Jason A. Clark @jasonclark

Professor, Machine Learning Librarian

Montana State University

​

Jason A. Clark

2026

2 of 31

What’s the problem?

Jason A. Clark

2026

3 of 31

Problem Statement

November 30, 2022

​

We were given access to a weirdly confident intern that can’t explain how they got their answers.

​

​

It is a seamless interface that breaks search interaction + retrieval patterns.

​

​

​

​

Jason A. Clark

2026

Jason A. Clark

2026

4 of 31

Problem Statement

Jason A. Clark

2026

Jason A. Clark

2026

5 of 31

Problem Statement

More crawling, fewer referrals.

​

More telling, less linking.

​

​

It is a seamless interface that breaks search interaction + retrieval patterns.

​

​

​

Source: “The crawl before the fall… of referrals” Cloudflare Radar

​

Jason A. Clark

2025

Jason A. Clark

2025

6 of 31

What can we do?

Jason A. Clark

2026

7 of 31

Research Motivation - Speculative Design, Frictional AI, Seamful Design

Rethink the human-computer interaction.

​

An artifactual interface that shows the work of semantic retrieval?

Jason A. Clark

2026

Jason A. Clark

2026

8 of 31

Prototype - “Agentic Search” Artifact using Small Language Models

Jason A. Clark

2026

Jason A. Clark

2026

9 of 31

Prototype - “Agentic Semantic Search” Artifact

Agent Label + “Thinking”

Observation to Focus Context

Jason A. Clark

2026

Jason A. Clark

2026

10 of 31

Prototype - “Agentic Semantic Search” Artifact

Clear Action

Final Answer with Sources

Trust Signal

Jason A. Clark

2026

Jason A. Clark

2026

11 of 31

Wait… Why? How?

Jason A. Clark

2026

12 of 31

Why? How?

Take advantage of the affordances of the dialogic chat interface.

  • Use small, sustainable models (green) that run on devices - rapid prototyping.
  • Condition the system prompt - optimize for discrete agentic tasks.
  • Limit the sources that the small language model can use - Wikipedia, Custom Dataset.
  • Activate semantic inference techniques inherent in LLM.
  • Connect these inference techniques to the search retrieval interface.

​

​

​

​

​

​

​

​

Jason A. Clark

2026

Jason A. Clark

2026

13 of 31

System Prompt - ReAct (Reasoning + Acting) Cycle (30 lines of directions, excerpted…)

# MSU Research Agent Prompt

​

## Role and Goal

You are a **Research Assistant** for **Montana State University (MSU)**. Your sole goal is to answer user queries by gathering, evaluating, and synthesizing information using the available tools, focusing exclusively on MSU expertise.

​

## Core Process: The ReAct Cycle

You **MUST** operate using the **Thought -> Action -> Observation** cycle until the query is fully answered.

​

### **Source of Truth and Reasoning:**

1. **Observations are your absolute source of truth.** You must rely **only** on the information returned in your `Observation:` steps.

2. **You must ignore all foundational model knowledge.** If your observations contradict your pre-existing knowledge, **the observation is correct.**

3. Your `Thought:` must explicitly state your reasoning, evaluate observations, and formulate the plan for the *next single step*.

4. Execute *exactly one* `Action:` per cycle.

​

## Available Tools and Strategy

* **Action Format:** `Action: tool_name: query`

* **Tool Limitation:** You only have the two tools listed below.

​

Source: Complete System Prompt available here.

Jason A. Clark

2026

Jason A. Clark

2026

14 of 31

Semantic Search - Wikipedia (prompt) (30 lines of directions, excerpted…)

# MSU Research Agent Prompt

​

….

​

## Available Tools

​

| Tool | Purpose | Example |

| :--- | :--- | :--- |

| `wikipedia: [query]` | General concepts only. Use to find keywords and technical terms. Do not assume any person mentioned is affiliated with MSU. | `Action: wikipedia: deep learning` |

| `search_msu_expertise: [query]` | **Your exclusive tool** for locating MSU faculty, labs, and programs. Use keywords gathered from wikipedia to sharpen queries. | `Action: search_msu_expertise: convolutional neural networks` |

​

## Stop Condition and Final Answer Format

​

Source: Complete System Prompt available here.

Jason A. Clark

2026

Jason A. Clark

2026

15 of 31

Semantic Search - Wikipedia (code)

def stream_query(question, max_turns=5, max_msu_searches=3):

i = 0

bot = Agent(system_prompt)

max_wikipedia_calls = 1

wikipedia_calls = 0

msu_searches = 0

​

if max_turns <= 0:

return

​

try:

# Deterministic first step: use Wikipedia once for concepts/keywords.

i += 1

first_thought = "I need general concepts and keywords before searching MSU expertise."

action = "wikipedia"

action_input = question

yield 'thought', first_thought

yield 'action', f"{action}: {action_input}"

Source: Complete Search Agent available here.

Jason A. Clark

2026

Jason A. Clark

2026

16 of 31

Local Dataset - Grounded Retrieval (code)

def search_msu_expertise(query):

"""Performs a search for MSU expertise and researcher interests.

​

Args:

query: The search query in the custom search engine.

​

Returns:

A dictionary containing a list of dictionaries, where each inner

dictionary contains 'title', 'link', 'snippets', and 'description'

for each search result.

"""

# Set up your own local dataset or database to query and ground search agent retrieval in a library or archive collection

"""

url = f"https://discoveryengine.googleapis.com/v1/projects/{projectID}/locations/global/collections/default_collection/engines/{agentID}/servingConfigs/default_search:searchLite?key={apiKey}"

​

​

Source: Complete Search Agent available here.

Jason A. Clark

2026

Jason A. Clark

2026

17 of 31

So, What?

Jason A. Clark

2026

18 of 31

Research Results - Speculative Design, Frictional AI, Seamful Design

  • A working artifact that addresses changing search interaction patterns.

​

  • An AI experiment that leads to AI Literacy.

​

  • Take a step toward trustworthy AI.

​

  • Use in your own teaching/learning about GenAI.

Jason A. Clark

2026

Jason A. Clark

2026

19 of 31

Research Implication - Semantic Search Formula using Agentic Patterns

Tool 1:

Semantic query refinement tool: LLM directed to interpret the underlying meaning, context, and intent of a user's query rather than just matching keywords..

+

Pass through the LLM’s semantic interpretation of the query to a retrieval tool and dataset.

+

Tool 2:

Retrieval Tool: uses interpreted query to search a local data source (database, spreadsheet, series of JSON files, etc.)

​

Jason A. Clark

2026

Jason A. Clark

2026

20 of 31

Research Implication - What is your Semantic Search + Agent Formula?

Tool 1:

E.g., Wikidata API term refinement

+

Pass through the LLM’s semantic interpretation of the query to a retrieval tool and dataset

+

Tool 2:

E.g., Search of National Archives Catalog (https://www.archives.gov/research/catalog/help/api).

​

​

​

Jason A. Clark

2026

Jason A. Clark

2026

21 of 31

Take this System Prompt into your Teaching + Instruction

# MSU Research Agent Prompt

​

## Role and Goal

You are a **Research Assistant** for **Montana State University (MSU)**. Your sole goal is to answer user queries by gathering, evaluating, and synthesizing information using the available tools, focusing exclusively on MSU expertise.

​

## Core Process: The ReAct Cycle

You **MUST** operate using the **Thought -> Action -> Observation** cycle until the query is fully answered.

​

### **Source of Truth and Reasoning:**

1. **Observations are your absolute source of truth.** You must rely **only** on the information returned in your `Observation:` steps.

2. **You must ignore all foundational model knowledge.** If your observations contradict your pre-existing knowledge, **the observation is correct.**

3. Your `Thought:` must explicitly state your reasoning, evaluate observations, and formulate the plan for the *next single step*.

4. Execute *exactly one* `Action:` per cycle.

​

## Available Tools and Strategy

* **Action Format:** `Action: tool_name: query`

* **Tool Limitation:** You only have the two tools listed below.

​

Source: Complete System Prompt available here.

Jason A. Clark

2026

Jason A. Clark

2026

22 of 31

Push our values and data into these systems. Claude MCP Integration

Integration with Consumer LLM

Jason A. Clark

2026

Jason A. Clark

2026

23 of 31

Push our values and data into these systems. Claude MCP Integration

Trust Signal + Sources in Consumer LLM

Jason A. Clark

2026

Jason A. Clark

2026

24 of 31

Research Implication

Language Models + Agentic Search

- Try and practice through implementation.

- Natural Language Interfaces + language models for retrieval are here.

- Adopt your own formula.

​

​

​

​

Jason A. Clark

2026

Jason A. Clark

2026

25 of 31

Latent Space Knowledge Graphs as World Models for Word Models:

An Alternative to GraphRAG for LLM Retrieval and Analysis

​

Jason A. Clark (Montana State University)

Helen Williams (London School of Economics)

​

​

AI Literacy Summit

2026

26 of 31

Additional Research - Project Details

Can language models have world models?

​

Can language models use/intepret graph data?

  • Address the deficit using a latent space knowledge graph: a compressed, machine-readable representation of the institutional world in which the model can operate.

​

  • Activate a LM’s pretrained capacity to interpret graph-structured data, enabling the reuse of linked data corpora for analysis and retrieval.

​

  • Test this approach across 3 distinct LAM corpora and tasks.

​

  • Success metrics: knowledge-graph-grounded approach against a web-retrieval-based LLM baseline on retrieval relevance (Hit Rate@5), recommendation quality (Precision@5), and domain validity.

​

​

​

​

​

​

​

​

AI Literacy Summit

2026

27 of 31

Additional Research

Code repository

https://github.com/jasonclark/kg-world-model-retrieval

​

Code and Sample N-Triple file - knowledge-graph-grounded LLM

https://gist.github.com/jasonclark/a6f5f832077da8546726888d16b25692

​

Slides

Knowledge Graphs and World Models for Retrieval and Analysis [talk Fantastic Futures 2026]

Previous research:�Clark, J. A., Williams, H. K. R., & Rossmann, D. (2022). Wikidata and knowledge graphs in practice: Using semantic SEO to create discoverable, accessible, machine‑readable definitions of the people, places, and services in Libraries and Archives. Information Services and Use, 42(3‑4), 377‑390. https://doi.org/10.3233/ISU-22017

AI Literacy Summit

2026

28 of 31

**Thank you**

​

Jason A. Clark

jaclark@montana.edu

​

@jasonclark

(Bluesky + GitHub)

Jason A. Clark

2026

29 of 31

Development Stack - “Agentic Search” Artifact using Small Language Models

  • Small Language Models (featured, others tested)
    • Phi-4-mini (2.5gb)
    • Llama 3.2:3b-instruct-q2_K (1.4gb)

​

  • Python
    • Flask
    • HTTP packages (httpx, httpcore)

​

  • HTML, CSS, and Javascript

​

Source: github.com/jasonclark/agentic-search-react

Jason A. Clark

2026

Jason A. Clark

2026

30 of 31

Language Models - Tools and Getting Started

  • Context Engineering

​

  • Running Local Language Models
    • Ollama
    • LM Studio

​

  • Example Code (Gists)

​

Jason A. Clark

2026

Jason A. Clark

2026

31 of 31

References and Follow-up Resources

Clarivate. (2025). Pulse of the library 2025: Global survey of academic, public and national libraries on how AI and other emerging priorities are shaping the future of libraries. https://clarivate.com/pulse-of-the-library/

​

Dunne, A., & Raby, F. (2013). Speculative everything: Design, fiction, and social dreaming. The MIT Press.

https://mitpress.mit.edu/9780262019842/speculative-everything/

​

Ericson, P., Khairova, N., & De Vos, M. (Eds.). (2024). HHAI-WS 2024: Proceedings of the Workshops at the Third International Conference on Hybrid Human-Artificial Intelligence (co-located with HHAI 2024), Malmö, Sweden, June 10–11, 2024. https://ceur-ws.org/Vol-3825/ (Frictional AI Workshop)

​

Natali, C., Naiseh, M., Cabitza, F., & Frischmann, B. (2025). Better AI with designed friction: Theories, applications and research agenda. In Frontiers in Artificial Intelligence and Applications: Vol. 408: HHAI 2025 (pp. 518–521). IOS Press. https://doi.org/10.3233/FAIA250680

​

Upol Ehsan, Q. Vera Liao, Samir Passi, Mark O. Riedl, and Hal Daumé III. (2024.) Seamful XAI: Operationalizing Seamful Design in Explainable AI. Proc. ACM Hum.-Comput. Interact. 8, CSCW1, Article 119 (April 2024), 29 pages. https://doi.org/10.1145/3637396

Jason A. Clark

2026

Jason A. Clark

2026