Initial commit: LLM workshop materials
Five modules covering nanoGPT, Ollama, RAG, semantic search, and neural networks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
1604671d36
56 changed files with 5577 additions and 0 deletions
274
03-rag/README.md
Normal file
274
03-rag/README.md
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
# Large Language Models Part III: Retrieval-Augmented Generation
|
||||
|
||||
**CHEG 667-013 — Chemical Engineering with Computers**
|
||||
Department of Chemical and Biomolecular Engineering, University of Delaware
|
||||
|
||||
---
|
||||
|
||||
## Key idea
|
||||
|
||||
Build a local, privacy-preserving RAG system that answers questions about your own documents.
|
||||
|
||||
## Key goals
|
||||
|
||||
- Understand the RAG workflow: chunk, embed, store, retrieve, generate
|
||||
- Build a vector store from a document collection
|
||||
- Query the vector store and generate responses with a local LLM
|
||||
- Experiment with parameters that affect retrieval quality
|
||||
|
||||
---
|
||||
|
||||
In Parts I and II, we trained a small GPT from scratch and then ran pre-trained models locally with `ollama`. We even used `ollama` on the command line to summarize documents. But what if we want to ask questions about a *specific* collection of documents — our own notes, emails, papers, or lab reports — rather than relying on what the model was trained on?
|
||||
|
||||
This is the idea behind **Retrieval-Augmented Generation (RAG)**. Instead of hoping the LLM "knows" the answer, we:
|
||||
|
||||
1. **Chunk** our documents into short text segments
|
||||
2. **Embed** each chunk into a vector (a list of numbers that captures its meaning)
|
||||
3. **Store** the vectors in a searchable index
|
||||
4. At query time, **embed** the user's question the same way
|
||||
5. **Retrieve** the most similar chunks using cosine similarity
|
||||
6. **Generate** a response by passing those chunks to an LLM as context
|
||||
|
||||
The LLM never sees your full document collection — only the most relevant pieces. Everything runs locally. No data leaves your machine.
|
||||
|
||||

|
||||
|
||||
|
||||
## 1. Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
You need:
|
||||
- Python 3.10+
|
||||
- `ollama` installed and working (from Part II)
|
||||
- About 2–3 GB of disk space for models
|
||||
|
||||
### Create a virtual environment
|
||||
|
||||
```bash
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
Or with `uv`:
|
||||
|
||||
```bash
|
||||
uv venv .venv
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
### Install the required packages
|
||||
|
||||
```bash
|
||||
pip install llama-index-core llama-index-readers-file \
|
||||
llama-index-llms-ollama llama-index-embeddings-huggingface \
|
||||
python-dateutil
|
||||
```
|
||||
|
||||
The `llama-index-*` packages are components of the [LlamaIndex](https://docs.llamaindex.ai/en/stable/) framework, which provides the plumbing for building RAG systems. `python-dateutil` is used by `clean_eml.py` for parsing email dates.
|
||||
|
||||
A `requirements.txt` is provided:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Pull the LLM
|
||||
|
||||
We will use the `command-r7b` model, which was fine-tuned for RAG tasks:
|
||||
|
||||
```bash
|
||||
ollama pull command-r7b
|
||||
```
|
||||
|
||||
Other models work too — `llama3.1:8B`, `deepseek-r1:8B`, `gemma3:1b` — but `command-r7b` tends to follow retrieval-augmented prompts well.
|
||||
|
||||
### Cache the embedding model
|
||||
|
||||
The embedding model converts text into vectors. We use `BAAI/bge-large-en-v1.5`, a sentence transformer hosted on Huggingface. It will download automatically on first use (~1.3 GB), but you can pre-cache it with a short Python script:
|
||||
|
||||
```python
|
||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||
embed_model = HuggingFaceEmbedding(
|
||||
cache_folder="./models",
|
||||
model_name="BAAI/bge-large-en-v1.5"
|
||||
)
|
||||
```
|
||||
|
||||
Save this as `cache_model.py` and run it:
|
||||
|
||||
```bash
|
||||
python cache_model.py
|
||||
```
|
||||
|
||||
|
||||
## 2. The documents
|
||||
|
||||
The `data/` directory contains 10 emails from the University of Delaware president's office, spanning 2012–2025 (the same set from Part II). Each is a plain text file with a subject line, date, and body text.
|
||||
|
||||
```bash
|
||||
ls data/
|
||||
```
|
||||
|
||||
In a real project, you might have PDFs, lab reports, research papers, or notes. For this exercise, the emails give us a small, manageable collection to work with.
|
||||
|
||||
### Preparing your own documents
|
||||
|
||||
If you have email files (`.eml` format), the script `clean_eml.py` can convert them to plain text:
|
||||
|
||||
```bash
|
||||
# Place .eml files in ./eml, then run:
|
||||
python clean_eml.py
|
||||
```
|
||||
|
||||
This extracts the subject, date, and body from each email and writes a dated `.txt` file to `./data`.
|
||||
|
||||
|
||||
## 3. Building the vector store
|
||||
|
||||
The script `build.py` does the heavy lifting:
|
||||
|
||||
1. Loads all text files from `./data`
|
||||
2. Splits them into **chunks** of 500 tokens with 50 tokens of overlap
|
||||
3. Embeds each chunk using the `BAAI/bge-large-en-v1.5` model
|
||||
4. Saves the vector store to `./storage`
|
||||
|
||||
```bash
|
||||
python build.py
|
||||
```
|
||||
|
||||
You should see progress bars as documents are parsed and embeddings are generated:
|
||||
|
||||
```
|
||||
Parsing nodes: 100%|████| 10/10 [00:00<00:00, 79.53it/s]
|
||||
Generating embeddings: 100%|████| 42/42 [00:05<00:00, 8.01it/s]
|
||||
Index built and saved to ./storage
|
||||
```
|
||||
|
||||
After this, the `./storage` directory contains JSON files with the vector data, document metadata, and index information. You only need to build once — queries will load from storage.
|
||||
|
||||
### What are chunks?
|
||||
|
||||
We can't embed an entire document as a single vector — it would lose too much detail. Instead, we split the text into overlapping segments. The **chunk size** (500 tokens) controls how much text each vector represents. The **overlap** (50 tokens) ensures that sentences at chunk boundaries aren't lost. The `SentenceSplitter` tries to break at sentence boundaries rather than mid-sentence.
|
||||
|
||||
> **Exercise 1:** Look at `build.py`. What would happen if you made the chunks much smaller (e.g., 100 tokens)? Much larger (e.g., 2000 tokens)? Think about the tradeoff between precision and context.
|
||||
|
||||
|
||||
## 4. Querying the vector store
|
||||
|
||||
The script `query.py` loads the stored index, takes your question, and returns a response grounded in the documents:
|
||||
|
||||
```bash
|
||||
python query.py
|
||||
```
|
||||
|
||||
```
|
||||
Enter a search topic or question (or 'exit'): Find documents about campus safety
|
||||
```
|
||||
|
||||
Here's what happens behind the scenes:
|
||||
|
||||
1. Your query is embedded into a vector using the same embedding model
|
||||
2. The 15 most similar chunks are retrieved (`similarity_top_k=15`)
|
||||
3. Those chunks are passed to `command-r7b` via `ollama` as context
|
||||
4. The LLM generates a response based *only* on the retrieved context
|
||||
|
||||
The custom prompt in `query.py` instructs the model to:
|
||||
- Base its response only on the provided context
|
||||
- Prioritize higher-ranked (more similar) snippets
|
||||
- Reference specific files and passages
|
||||
- Format the output as a theme summary plus a list of matching files
|
||||
|
||||
### Example output
|
||||
|
||||
```
|
||||
Enter a search topic or question (or 'exit'): Find documents that highlight
|
||||
the excellence of the university
|
||||
|
||||
1. **Summary Theme**
|
||||
The dominant theme across these documents is the University of Delaware's
|
||||
commitment to excellence, innovation, and community impact...
|
||||
|
||||
2. **Matching Files**
|
||||
2024_08_26_100859.txt - Welcome message highlighting UD's mission...
|
||||
2023_10_12_155349.txt - Affirming institutional purpose and values...
|
||||
...
|
||||
|
||||
Source documents:
|
||||
2024_08_26_100859.txt 0.6623
|
||||
2023_10_12_155349.txt 0.6451
|
||||
...
|
||||
|
||||
Elapsed time: 76.1 seconds
|
||||
```
|
||||
|
||||
Notice the **similarity scores** — these are cosine similarities between the query vector and each chunk's vector. Higher is more relevant. Also note that the search is *semantic*: the query said "excellence" but the matching documents talk about "achievement," "mission," and "purpose." The embedding model understands meaning, not just keywords.
|
||||
|
||||
> **Exercise 2:** Run the same query twice. Do you get exactly the same output? Why or why not?
|
||||
|
||||
|
||||
## 5. Understanding the pieces
|
||||
|
||||
### The embedding model
|
||||
|
||||
The embedding model (`BAAI/bge-large-en-v1.5`) maps text to a 1024-dimensional vector. Two pieces of text with similar meaning will have vectors that point in similar directions (high cosine similarity), even if they use different words. This is what makes semantic search possible.
|
||||
|
||||
### The LLM
|
||||
|
||||
The LLM (`command-r7b` via `ollama`) is the *generator*. It reads the retrieved chunks and composes a coherent answer. Without the retrieval step, it would rely only on its training data — which knows nothing about your specific documents.
|
||||
|
||||
### The prompt
|
||||
|
||||
The default LlamaIndex prompt is simple:
|
||||
|
||||
```
|
||||
Context information is below.
|
||||
---------------------
|
||||
{context_str}
|
||||
---------------------
|
||||
Given the context information and not prior knowledge, answer the query.
|
||||
Query: {query_str}
|
||||
Answer:
|
||||
```
|
||||
|
||||
Our custom prompt in `query.py` is more detailed — it asks for structured output and tells the model to cite sources. You can inspect and modify the prompt to change the model's behavior.
|
||||
|
||||
> **Exercise 3:** Modify the prompt in `query.py`. For example, ask the model to respond in the style of a news reporter, or to focus only on dates and events. How does the output change?
|
||||
|
||||
|
||||
## 6. Exercises
|
||||
|
||||
> **Exercise 4:** Try different embedding models. Replace `BAAI/bge-large-en-v1.5` with `sentence-transformers/all-mpnet-base-v2` in both `build.py` and `query.py`. Rebuild the vector store and compare the results.
|
||||
|
||||
> **Exercise 5:** Change the chunk size and overlap in `build.py`. Try `chunk_size=200, chunk_overlap=25` and then `chunk_size=1000, chunk_overlap=100`. Rebuild and query. What differences do you notice?
|
||||
|
||||
> **Exercise 6:** Swap the LLM. Try `llama3.2` or `gemma3:1b` instead of `command-r7b`. Which gives better RAG responses? Why might some models be better at following retrieval-augmented prompts?
|
||||
|
||||
> **Exercise 7:** Bring your own documents. Find a collection of text files — research paper abstracts, class notes, or a downloaded text from Project Gutenberg — and build a RAG system over them. What questions can you answer that a plain LLM cannot?
|
||||
|
||||
|
||||
## Additional resources and references
|
||||
|
||||
### LlamaIndex
|
||||
|
||||
- Documentation: https://docs.llamaindex.ai/en/stable/
|
||||
|
||||
### Models
|
||||
|
||||
- Ollama: https://ollama.com
|
||||
- Huggingface models: https://huggingface.co/models
|
||||
|
||||
#### Models used in this tutorial
|
||||
|
||||
| Model | Type | Role | Source |
|
||||
|-------|------|------|--------|
|
||||
| `command-r7b` | LLM (RAG-optimized) | Response generation | `ollama pull command-r7b` |
|
||||
| `BAAI/bge-large-en-v1.5` | Embedding (1024-dim) | Text -> vector encoding | Huggingface (auto-downloaded) |
|
||||
|
||||
Other LLMs mentioned: `llama3.1:8B`, `deepseek-r1:8B`, `gemma3:1b`, `llama3.2`
|
||||
Other embedding model mentioned: `sentence-transformers/all-mpnet-base-v2`
|
||||
|
||||
### Further reading
|
||||
|
||||
- NIST IR 8579, [*Developing the NCCoE Chatbot: Technical and Security Learnings from the Initial Implementation*](https://csrc.nist.gov/pubs/ir/8579/ipd) ([PDF](https://nvlpubs.nist.gov/nistpubs/ir/2025/NIST.IR.8579.ipd.pdf)) — practical guidance on building a RAG-based chatbot, including architecture and security considerations
|
||||
- Open WebUI (https://openwebui.com) — a turnkey local RAG interface if you want a GUI
|
||||
49
03-rag/build.py
Normal file
49
03-rag/build.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# build.py
|
||||
#
|
||||
# Import documents from data, generate embedded vector store
|
||||
# and save to disk in directory ./storage
|
||||
#
|
||||
# August 2025
|
||||
# E. M. Furst
|
||||
|
||||
from llama_index.core import (
|
||||
SimpleDirectoryReader,
|
||||
VectorStoreIndex,
|
||||
Settings,
|
||||
)
|
||||
|
||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||
from llama_index.core.node_parser import SentenceSplitter
|
||||
|
||||
def main():
|
||||
# Choose your embedding model
|
||||
embed_model = HuggingFaceEmbedding(cache_folder="./models",
|
||||
model_name="BAAI/bge-large-en-v1.5")
|
||||
|
||||
# Configure global settings for LlamaIndex
|
||||
Settings.embed_model = embed_model
|
||||
|
||||
# Load documents
|
||||
documents = SimpleDirectoryReader("./data").load_data()
|
||||
|
||||
# Create the custom textsplitter
|
||||
# Set chunk size and overlap (e.g., 256 tokens, 25 tokens overlap)
|
||||
text_splitter = SentenceSplitter(
|
||||
chunk_size=500,
|
||||
chunk_overlap=50,
|
||||
)
|
||||
Settings.text_splitter = text_splitter
|
||||
|
||||
# Build the index
|
||||
index = VectorStoreIndex.from_documents(
|
||||
documents, transformations=[text_splitter],
|
||||
show_progress=True,
|
||||
)
|
||||
|
||||
# Persist both vector store and index metadata
|
||||
index.storage_context.persist(persist_dir="./storage")
|
||||
|
||||
print("Index built and saved to ./storage")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
12
03-rag/cache_model.py
Normal file
12
03-rag/cache_model.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# cache_model.py
|
||||
#
|
||||
# Pre-download the embedding model so build.py doesn't have to fetch it.
|
||||
|
||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||
|
||||
embed_model = HuggingFaceEmbedding(
|
||||
cache_folder="./models",
|
||||
model_name="BAAI/bge-large-en-v1.5"
|
||||
)
|
||||
|
||||
print("Embedding model cached in ./models")
|
||||
48
03-rag/clean_eml.py
Normal file
48
03-rag/clean_eml.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# clean_eml.py
|
||||
#
|
||||
# Convert .eml files to plain text files for use with build.py.
|
||||
# Place .eml files in ./eml, then run this script to produce
|
||||
# dated .txt files in ./data.
|
||||
#
|
||||
# August 2025
|
||||
# E. M. Furst
|
||||
|
||||
from email import policy
|
||||
from email.parser import BytesParser
|
||||
from pathlib import Path
|
||||
from dateutil import parser
|
||||
from dateutil import tz
|
||||
|
||||
eml_dir = "eml"
|
||||
out_dir = "data"
|
||||
|
||||
for eml_file in Path(eml_dir).glob("*.eml"):
|
||||
with open(eml_file, "rb") as f:
|
||||
msg = BytesParser(policy=policy.default).parse(f)
|
||||
|
||||
# Get metadata
|
||||
subject = msg.get("subject", "No Subject")
|
||||
date = msg.get("date", "No Date")
|
||||
|
||||
# Convert date to a safe format for filenames: YYYY_MM_DD_hhmmss
|
||||
date = parser.parse(date)
|
||||
if date.tzinfo is None:
|
||||
date = date.replace(tzinfo=tz.tzlocal())
|
||||
date = date.astimezone(tz.tzlocal())
|
||||
msg_date = date.strftime("%d/%m/%Y, %H:%M:%S")
|
||||
date = date.strftime("%Y_%m_%d_%H%M%S")
|
||||
|
||||
# Prefer plain text, fallback to HTML
|
||||
body_part = msg.get_body(preferencelist=('plain', 'html'))
|
||||
if body_part:
|
||||
body_content = body_part.get_content()
|
||||
else:
|
||||
body_content = msg.get_payload()
|
||||
|
||||
# Combine into a clean string with labels and newlines
|
||||
text = f"Subject: {subject}\nDate: {date}\n\n{body_content}"
|
||||
|
||||
out_file = Path(f"{out_dir}/{date}.txt").open("w", encoding="utf-8")
|
||||
out_file.write(text)
|
||||
|
||||
print(f"{msg_date}")
|
||||
80
03-rag/data/2012_11_02_164248.txt
Normal file
80
03-rag/data/2012_11_02_164248.txt
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
Subject: [UDEL-ALL-2128] Hurricane Sandy
|
||||
Date: 2012_11_02_164248
|
||||
|
||||
To the University of Delaware community:
|
||||
|
||||
We have much to be thankful for this week at the University of Delaware
|
||||
as we were spared the full force of Hurricane Sandy. Even as we breathe
|
||||
a sigh of relief and return to our normal activities, we are mindful of
|
||||
the many, many people in this region -- some of our students among them
|
||||
-- who were not so lucky. Our thoughts and prayers go out to them as
|
||||
they rebuild their communities.
|
||||
|
||||
The potential impact of Sandy was a major concern for UD, with its
|
||||
thousands of people and 430+ buildings on 2,000 acres throughout the
|
||||
state. Many members of our University community worked hard over the
|
||||
last several days to help us weather this "Storm of the Century."
|
||||
|
||||
Preparation and practice paid off as our emergency response team, led
|
||||
by the Office of Campus and Public Safety, began assessing the
|
||||
situation late last week and taking steps to ensure the safety of our
|
||||
people and facilities. When the storm came, the campus suffered only
|
||||
minor damage: wind-driven water getting into buildings through roofs,
|
||||
walls and foundations; very minimal power loss, with a couple of
|
||||
residential properties without power for only a few hours, thanks to
|
||||
quick repair from the City of Newark; and only three trees knocked down
|
||||
and destroyed, along with a lot of leaves and branches to clean up. The
|
||||
Georgetown research facilities were fortunate to sustain only minor
|
||||
leaks and flooding. The hardest hit area was the Lewes campus, which
|
||||
had flooding on its grounds but minimal damage to buildings.
|
||||
|
||||
Throughout this time, the University's greatest asset continued to be
|
||||
its people -- staff members from a variety of units working as a team.
|
||||
A command center brought together representatives from across UD so
|
||||
that issues could be responded to immediately. Staffed around the
|
||||
clock, the center included Housing, Public Safety, Residence Life,
|
||||
Environmental Health and Safety, Facilities and Auxiliary Services,
|
||||
Emergency Management, and Communications and Marketing.
|
||||
|
||||
The dedication of UD's employees and students was evident everywhere:
|
||||
Dining Services staff, faced with reduced numbers and limited
|
||||
deliveries, kept students fed, and supported employees who worked
|
||||
during the crisis; Residence Life staff and resident assistants made
|
||||
sure students who remained on campus had up-to-date information and
|
||||
supplies; staff in Student Health Services kept Laurel Hall open to
|
||||
respond to student health needs; Human Resources staff worked over the
|
||||
weekend to ensure that payroll was processed ahead of time; UD Police
|
||||
officers were on patrol and responding to issues as they arose; the UD
|
||||
Emergency Care Unit was at the ready; staff in Environmental Health and
|
||||
Safety aided in the safe shutdown of UD laboratories and monitored fire
|
||||
safety issues; Facilities staff continue to clean up debris left in
|
||||
Sandy's wake and repair damage to buildings; faculty are working with
|
||||
students to make up lost class time.
|
||||
|
||||
Our UD Alert system served as an excellent tool for keeping students,
|
||||
parents and employees informed about the storm's implications for UD,
|
||||
and the University's homepage was the repository for the most current
|
||||
information and lists of events and activities that were canceled or
|
||||
rescheduled. Through the University's accounts on Facebook and Twitter,
|
||||
staff answered questions and addressed concerns, and faculty and staff
|
||||
across the campus fielded phone calls and emails.
|
||||
|
||||
In short, a stellar job all around.
|
||||
|
||||
On behalf of the students, families and employees who benefited from
|
||||
these efforts, I thank everyone for their dedication and service to the
|
||||
people of UD.
|
||||
|
||||
Sincerely,
|
||||
|
||||
Patrick T. Harker
|
||||
President
|
||||
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::: UD P.O. Box ::
|
||||
UDEL-ALL-2128 mailing list
|
||||
|
||||
Online message archive
|
||||
and management at https://po-box.nss.udel.edu/
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
85
03-rag/data/2017_05_16_123456.txt
Normal file
85
03-rag/data/2017_05_16_123456.txt
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
Subject: Employee Appreciation Week
|
||||
Date: 2017_05_16_123456
|
||||
|
||||
To the University of Delaware Community - President Dennis Assanis
|
||||
|
||||
|
||||
|
||||
/* Smartphones (landscape) ----------- */
|
||||
|
||||
@media only screen and (max-width: 568px) {
|
||||
img.logo {width:413px;}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
May 16, 2017
|
||||
|
||||
Dear colleague,
|
||||
|
||||
|
||||
Our first year together has been one of amazing accomplishments and exciting opportunities. At the heart of our success has been you — the University of Delaware’s exceptional faculty and staff. To thank you and celebrate everything you do, we are launching our first Employee Appreciation Week.
|
||||
|
||||
The full week of events includes:
|
||||
|
||||
|
||||
Monday, June 5—UDidIt Picnic
|
||||
|
||||
Tuesday, June 6—Self-Care Day
|
||||
Wednesday, June 7—UD Spirit Day
|
||||
Thursday, June 8—Flavors of UD
|
||||
|
||||
Friday, June 9—Employee Appreciation Night at the Blue Rocks
|
||||
|
||||
The week is a collaborative effort by Employee Health & Wellbeing and Human Resources. You can get all the details here.
|
||||
|
||||
We are dedicated to cultivating together an environment where employees are happy, healthy and continue to bring their best selves to work each day. The work you do benefits our students, our community and the world. I am truly grateful for your talents, skills, ideas and enduring commitment to the University.
|
||||
|
||||
Eleni and I hope you enjoy Employee Appreciation Week with your team and your family, and we look forward to seeing you at the many events.
|
||||
|
||||
Best,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE 19716 • USA • (302) 831-2792 • www.udel.edu/president
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
img { display: block !important; }
|
||||
79
03-rag/data/2018_05_21_110335.txt
Normal file
79
03-rag/data/2018_05_21_110335.txt
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
Subject: Robin Morgan named UD's 11th provost
|
||||
Date: 2018_05_21_110335
|
||||
|
||||
Robin Morgan Appointed Provost - University of Delaware
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
May 21, 2018
|
||||
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
I am pleased to announce that, after a highly competitive national search, I have appointed Robin Morgan as the University of Delaware’s new provost, effective July 1. She will become the University of Delaware’s 11th provost, and the first woman to serve in this role in a permanent capacity since the position was created at UD in 1950.
|
||||
|
||||
Over the last seven months, Dr. Morgan already has assembled an impressive record as interim provost, most notably in her stewardship of new cluster hires among our faculty and her leadership as we move toward the creation of the graduate college.
|
||||
|
||||
Before working closely with her, I knew Dr. Morgan as a highly respected educator and scholar, but after watching her in action, I am equally impressed with her abilities to lead, inspire and effect change. Her energy, integrity, analytical mind, and innate knack for bringing people together, combined with her dedication and loyalty to UD, are great assets.
|
||||
|
||||
Dr. Morgan has a distinguished record of service to this University as a faculty member since 1985. After serving as acting dean of the College of Agriculture and Natural Resources for a year, she was named dean in 2002, serving in that role for 10 years, a period of significant growth and change for the college. From 2014-16, she served as acting chair of the Department of Biological Sciences, and she had been chair of the department from 2016 until her appointment as interim provost.
|
||||
|
||||
We will continue to benefit from Dr. Morgan’s deep knowledge of the University, her proven leadership across all aspects of teaching, research and administration, and her dedication to UD as she continues her career as provost.
|
||||
|
||||
I am looking forward to building on our close working relationship, and I am excited by all we will accomplish to take the University of Delaware forward. Please join me in congratulating her on this next chapter in her career.
|
||||
|
||||
|
||||
Sincerely,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE 19716 • USA • (302) 831-2111 • www.udel.edu/president
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
img { display: block !important; }
|
||||
77
03-rag/data/2020_03_29_141635.txt
Normal file
77
03-rag/data/2020_03_29_141635.txt
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
Subject: Momentum and Resilience: Our UD Spring Semester Resumes
|
||||
Date: 2020_03_29_141635
|
||||
|
||||
A Message from President Dennis Assanis
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
As the University of Delaware is ready to resume the spring semester tomorrow, March 30, I want to share with all of you a special message recorded from the office in my home. Thank you all for your support at this challenging time, particularly our faculty and staff for your Herculean efforts to convert our classes from face to face instruction to online teaching and learning.
|
||||
|
||||
Best of luck with the semester ahead. As we all work remotely, please stay healthy, and stay connected!
|
||||
|
||||
|
||||
|
||||
|
||||
Sincerely,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE 19716 • USA • (302) 831-2111 • udel.edu/president
|
||||
75
03-rag/data/2023_09_19_085321.txt
Normal file
75
03-rag/data/2023_09_19_085321.txt
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
Subject: National Voter Registration Day: Get Involved
|
||||
Date: 2023_09_19_085321
|
||||
|
||||
National Voter Registration Day: Get Involved
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
September 19, 2023
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
Do you want to make a difference in the world? Today is a good day to start.
|
||||
|
||||
This is National Voter Registration Day, an opportunity to make sure your voice will be heard in upcoming local, state and national elections. Voting is the most fundamental way that we engage in our democracy, effect change in society, work through our political differences and choose our leaders for the future. The voting rights we enjoy have been secured through the hard work and sacrifice of previous generations, and it is essential that everyone who is eligible to vote remains committed to preserving and exercising those rights.
|
||||
|
||||
At the University of Delaware, the Student Voting and Civic Engagement Committee — representing students, faculty and staff — is leading a non-partisan effort to encourage voting and help voters become better informed about the issues that matter to them. The Make It Count voter registration drive is scheduled for 2-6 p.m. today on The Green, with games, music and the opportunity to register through the TurboVote app, which also allows users to request an absentee ballot and sign up for election reminders. The committee is planning additional events this academic year to promote voting, education and civil discourse as the nation heads into the 2024 election season.
|
||||
|
||||
Being a Blue Hen means sharing a commitment to creating a better world. And being a registered, engaged and informed voter is one of the best ways for all of us to achieve that vision.
|
||||
|
||||
Sincerely,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE • udel.edu/president
|
||||
77
03-rag/data/2023_10_12_155349.txt
Normal file
77
03-rag/data/2023_10_12_155349.txt
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
Subject: Affirming our position and purpose
|
||||
Date: 2023_10_12_155349
|
||||
|
||||
Affirming our position and purpose | A message from UD President Dennis Assanis
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
October 12, 2023
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
Since my message yesterday, I have talked to many members of our community who — like me — are devastated and appalled by the terrorist attacks on Israel and the ongoing loss of life that has taken place in the Middle East.
|
||||
|
||||
I want to be sure that our position is very clear: We at the University of Delaware unequivocally condemn the horrific attacks by Hamas terrorists upon Israel that have shaken the world. The atrocities of crime, abduction, hostage-taking and mass murder targeted against Jewish civilians will forever remain a stain on human history. Our community’s foundation of civility and respect has been challenged to an unimaginable extent in light of the antisemitic brutalities that have been committed against innocent victims.
|
||||
|
||||
As your president, I wish words could calm the heartache and ease the fear and grief. Unfortunately, we all know that events as complicated and devastating as those taking place in the Middle East right now will continue to evolve. The longstanding humanitarian crisis needs to be acknowledged, and we should not equate the terrorist group Hamas with innocent Palestinian, Muslim and Arab people. The ensuing war-inflicted pain, suffering and death that continues to play out across the region, including Gaza, is heartbreaking for all.
|
||||
|
||||
We must remember that, first and foremost, UD is a place of learning. As we engage in difficult conversations about the longstanding conflicts in the Middle East, we should always strive to do so safely, with mutual respect and without bias or judgement. I encourage our students, faculty and staff to continues organizing events to educate and unite our community. Please seize these opportunities not only as individuals, but as members of a true community defined by the freedoms that we treasure so very deeply.
|
||||
|
||||
So, my message to you all is to have hope, to support each other, and to realize that the perspectives and feelings we are all experiencing right now — many of which uniquely connect to our personal backgrounds — matter. Please remember this as you walk across campus, sit in your next classroom, share experiences with other members of our community, or simply take time to reflect.
|
||||
|
||||
Respectfully,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE • udel.edu/president
|
||||
82
03-rag/data/2024_08_26_100859.txt
Normal file
82
03-rag/data/2024_08_26_100859.txt
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
Subject: A warm welcome to our UD community!
|
||||
Date: 2024_08_26_100859
|
||||
|
||||
A warm welcome to our UD community!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
August 26, 2024
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
I love the beginning of every new academic year and the renewed energy and sense of anticipation that it brings to every member of our campus community. The large influx of new people and ideas that come along with each new start is truly invigorating. Whether you are a new or continuing student, faculty or staff member, on behalf of everyone in our community, I want to extend a very warm welcome to you and thank you for everything you contribute, individually and collectively, to make the University of Delaware such a unique place.
|
||||
|
||||
Students, your fresh perspectives, your passion for learning, and your dreams and aspirations for the boundless possibilities that lie ahead are inspiring. Faculty, your intellectual energy, your insights and expertise, and above all, your genuine interest in transferring and sharing your knowledge with all of us are the beating heart of our institution. And to all our staff, your hard work and dedicated talents provide the essential support and services to help ensure our students are successful in all their personal, academic and career pursuits.
|
||||
|
||||
Here at UD, our shared purpose is to cultivate learning, develop knowledge and foster the free exchange of ideas. The connections we make and the relationships we build help advance the mission of the University. Our focus on academic excellence in all fields of study and our opportunities for groundbreaking research rely on our endless curiosity, mutual respect and open mindedness. Together, we are stronger.
|
||||
|
||||
This sense of connection and belonging at UD is fundamental to our campus culture. Your willingness to hear and consider all voices and viewpoints is critical to shaping the vibrant and inclusive culture of our entire institution. Only when we commit to constructive growth, based on a foundation of civility and respect for ourselves and each other, can we realize true progress. Empowered by diverse perspectives, it is the opportunities to advance ideas that enrich learning and create positive impact in the world that unite all of us.
|
||||
|
||||
To celebrate the new semester and welcome our undergraduate Class of 2028, all members of our community are invited to attend the Twilight Induction ceremony tonight at 7:30 p.m. on the north side of Memorial Hall or online on Facebook Live.
|
||||
|
||||
As your President, I am so excited by all that we can accomplish together throughout this academic year. My wife, Eleni, and I wish you all the best at the start of this new semester and beyond. We look forward to meeting you on campus!
|
||||
|
||||
|
||||
Sincerely,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE • udel.edu
|
||||
80
03-rag/data/2025_02_13_160414.txt
Normal file
80
03-rag/data/2025_02_13_160414.txt
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
Subject: UPDATE: Recent Executive Orders
|
||||
Date: 2025_02_13_160414
|
||||
|
||||
UPDATE: Recent Executive Orders | University of Delaware
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Feb. 13, 2025
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
I know many of you continue to experience disruption and anxiety stemming from the recent federal actions and executive orders regarding a multitude of issues — from research funding to education, human rights, and immigration among other areas. As I communicated to the University of Delaware community in my Jan. 28 campus message and my Feb. 3 comments to the Faculty Senate, we will do everything we can to minimize disruption to UD students, faculty and staff while remaining in compliance with federal law.
|
||||
|
||||
To support our community, we have created this resource page that will be updated regularly with information for UD students, faculty and staff regarding ongoing federal actions, directives and developments, including guidance in response to changing conditions. Also, this page from the Research Office contains specific guidance related to research projects and grants. In parallel, we will continue to advocate on behalf of the University’s interests regarding any impact that federal or state actions could have on our students, faculty and staff.
|
||||
|
||||
One example is our response this week related to the federal action to impose a 15 limit on reimbursements for indirect administrative costs (Facilities and Administrative, or F&A costs) for all National Institutes of Health (NIH) research grants. This immediate cut in funding would have a devastating impact on all biomedical, health and life science advances and human wellness, including here at UD. In response, the Delaware Attorney General filed a lawsuit jointly with 21 other state attorneys general. The University supported the Attorney General’s lawsuit by submitting a declaration detailing the impact of the NIH rate cap on the institution. Fortunately, the attorneys general were successful, and a temporary restraining order was granted on Monday. Further, the Association of Public and Land-grant Universities, the Association of American Universities, and the American Council on Education announced a similar lawsuit.
|
||||
|
||||
As we navigate this rapidly evolving landscape together, our values will continue to be at the heart of our community. We will continue to foster an atmosphere that promotes the free exchange of ideas and opinions; we will continue to welcome and value people of different backgrounds, perspectives and learning experiences; and we will continue to encourage respect and civility toward everyone.
|
||||
|
||||
Please know that my leadership team and I are here to help and support our community during this time. Feel free to submit any questions pertaining to these matters here, and we will do our best to add relevant information on the resource pages. I deeply appreciate your resilience and patience as we continue to work together to advance the important mission of our University.
|
||||
|
||||
|
||||
Sincerely,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE • udel.edu
|
||||
87
03-rag/data/2025_04_29_230614.txt
Normal file
87
03-rag/data/2025_04_29_230614.txt
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
Subject: Extending condolences and offering support
|
||||
Date: 2025_04_29_230614
|
||||
|
||||
Extending condolences and offering support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
April 29, 2025
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
It is with a heavy heart that we share this information with you. Earlier today, a University of Delaware student died in a traffic accident on Main Street near campus, and several other people, including other UD students, suffered injuries. There is no ongoing threat to the University community.
|
||||
|
||||
University of Delaware Police are continuing to work with the Newark Police Department, which is actively investigating the incident. As a result, information is limited and the Newark Police Department is not releasing the victims’ names at this time, pending family notification.
|
||||
|
||||
This is a terrible tragedy for everyone in our UD community. We speak for the entire University in offering our condolences to the families, friends and classmates of the victims, and keep the other members of our community in our thoughts who may have witnessed the crash and its aftermath. The safety of our entire community remains our top priority, and we will continue to work with our partners in city and state government to address safety concerns around and on the UD campus.
|
||||
|
||||
As we all begin to cope with this traumatic incident, we encourage you to support one another and reach out for additional help from the UD resources listed below as needed.
|
||||
|
||||
Sincerely,
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
José-Luis RieraVice President for Student Life
|
||||
|
||||
|
||||
|
||||
Support and resources
|
||||
|
||||
|
||||
Center for Counseling and Student Development
|
||||
|
||||
Counselors and Student Life staff are available in Warner Hall 101 on Wednesday, April 30, from 9 a.m. to 3 p.m. for counseling services.
|
||||
|
||||
|
||||
TimelyCare — A virtual health and wellbeing platform available 24/7 for UD students
|
||||
Student Advocacy and Support — Available to assist students who need support navigating University resources or complex issues. Call 302-831-8939 or email studentsupport@udel.edu to schedule an appointment.
|
||||
ComPsych® GuidanceResources® — Mental health support for UD benefited employees. Access services through the link or call 877-527-4742 for support.
|
||||
Additional safety and wellness resources — Information about UD Police, Student Health Services and other services.
|
||||
Information about the UD Alert, the LiveSafe app and safety notification communication.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE • udel.edu
|
||||
76
03-rag/data/2025_04_30_160615.txt
Normal file
76
03-rag/data/2025_04_30_160615.txt
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
Subject: Sharing our grief, enhancing safety
|
||||
Date: 2025_04_30_160615
|
||||
|
||||
Sharing our grief, enhancing safety
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
April 30, 2025
|
||||
|
||||
Dear UD Community,
|
||||
|
||||
Since last evening’s crash on Main Street that took the life of a University of Delaware graduate student (whose identity is being withheld at this time) and injured several others, we have been struggling to cope with the pain of this senseless tragedy. Throughout the UD community, we are all feeling the deep ache of loss, and we will continue to work through our grief together.
|
||||
|
||||
Today, Newark Police announced an arrest in connection with the crash, reiterating that there is no ongoing threat to the community.
|
||||
|
||||
Main Street is where we eat, shop and share our lives with our friends, families and classmates. Because it is part of the state’s roadway systems, we have been working with local and state officials this year, including our partners at Delaware Department of Transportation, to address traffic safety on and around Main Street. In the wake of this tragedy, we will reinforce and accelerate those efforts. We recognize there isn’t a simple solution, particularly when these tragedies involve actions taken by individuals that may not be stopped by changes to roadways or infrastructure. However, this incident underscores that our collective efforts must take on renewed urgency.
|
||||
|
||||
University leaders joined Delaware Attorney General Kathy Jennings and Newark Mayor Travis McDermott today for a press conference, at which we expressed our shared commitment to enhanced safety along Main Street. The University has pledged to continue these discussions through meetings with the offices of AG Jennings and Mayor McDermott, in addition to DelDOT, in the near future. The University remains committed to advancing meaningful solutions, while the University’s Division of Student Life and Graduate College are connecting with students about effective advocacy, civic engagement and partnerships in order to support these efforts.
|
||||
|
||||
We are also aware that members of the UD community may have witnessed the crash and its aftermath or have close relationships with the victims. We encourage everyone to become familiar with and use, as needed, the available University counseling and support resources that were shared in Tuesday evening’s message to the UD community. Counseling services are available at Warner Hall and through TimelyCare anytime, 24/7. Students with physical injuries or medical concerns relating to the incident can contact Student Health Services at 302-831-2226, Option 0, or visit Laurel Hall to meet with triage nurses available until 5 p.m. After hours, students can contact the Highmark Nurse line at 888-258-3428 or visit local urgent care centers (Newark Urgent Care at 324 E. Main Street, or ChristianaCare GoHealth at 550 S. College Avenue, Suite 115).
|
||||
|
||||
During this difficult time in our community, we all need to continue supporting and standing by one another as we move forward together.
|
||||
|
||||
Sincerely,
|
||||
|
||||
Dennis AssanisPresident
|
||||
|
||||
Laura CarlsonProvost
|
||||
|
||||
José-Luis RieraVice President for Student Life
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
University of Delaware • Newark, DE • udel.edu
|
||||
BIN
03-rag/img/rag-workflow.png
Normal file
BIN
03-rag/img/rag-workflow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 148 KiB |
110
03-rag/query.py
Normal file
110
03-rag/query.py
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
# query.py
|
||||
#
|
||||
# Run a query on a vector store
|
||||
#
|
||||
# August 2025
|
||||
# E. M. Furst
|
||||
|
||||
from llama_index.core import (
|
||||
load_index_from_storage,
|
||||
StorageContext,
|
||||
Settings,
|
||||
)
|
||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||
from llama_index.llms.ollama import Ollama
|
||||
from llama_index.core.prompts import PromptTemplate
|
||||
import os, time
|
||||
|
||||
#
|
||||
# Globals
|
||||
#
|
||||
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
||||
|
||||
# Embedding model used in vector store (this should match the one in build.py)
|
||||
embed_model = HuggingFaceEmbedding(cache_folder="./models",
|
||||
model_name="BAAI/bge-large-en-v1.5")
|
||||
|
||||
# LLM model to use in query transform and generation
|
||||
llm = "command-r7b"
|
||||
|
||||
#
|
||||
# Custom prompt for the query engine
|
||||
#
|
||||
PROMPT = PromptTemplate(
|
||||
"""You are an expert research assistant. You are given top-ranked writing \
|
||||
excerpts (CONTEXT) and a user's QUERY.
|
||||
|
||||
Instructions:
|
||||
- Base your response *only* on the CONTEXT.
|
||||
- The snippets are ordered from most to least relevant—prioritize insights \
|
||||
from earlier (higher-ranked) snippets.
|
||||
- Aim to reference *as many distinct* relevant files as possible (up to 10).
|
||||
- Do not invent or generalize; refer to specific passages or facts only.
|
||||
- If a passage only loosely matches, deprioritize it.
|
||||
|
||||
Format your answer in two parts:
|
||||
|
||||
1. **Summary Theme**
|
||||
Summarize the dominant theme from the relevant context in a few sentences.
|
||||
|
||||
2. **Matching Files**
|
||||
Make a list of 10 matching files. The format for each should be:
|
||||
<filename> - <rationale tied to content. Include date if available.>
|
||||
|
||||
CONTEXT:
|
||||
{context_str}
|
||||
|
||||
QUERY:
|
||||
{query_str}
|
||||
|
||||
Now provide the theme and list of matching files."""
|
||||
)
|
||||
|
||||
#
|
||||
# Main program routine
|
||||
#
|
||||
|
||||
def main():
|
||||
# Use a local model to generate -- in this case using Ollama
|
||||
Settings.llm = Ollama(
|
||||
model=llm,
|
||||
request_timeout=360.0,
|
||||
)
|
||||
|
||||
# Load embedding model (same as used for vector store)
|
||||
Settings.embed_model = embed_model
|
||||
|
||||
# Load persisted vector store + metadata
|
||||
storage_context = StorageContext.from_defaults(persist_dir="./storage")
|
||||
index = load_index_from_storage(storage_context)
|
||||
|
||||
# Build regular query engine with custom prompt
|
||||
query_engine = index.as_query_engine(
|
||||
similarity_top_k=15,
|
||||
text_qa_template=PROMPT,
|
||||
)
|
||||
|
||||
# Query
|
||||
while True:
|
||||
q = input("\nEnter a search topic or question (or 'exit'): ").strip()
|
||||
if q.lower() in ("exit", "quit"):
|
||||
break
|
||||
print()
|
||||
|
||||
# Generate the response by querying the engine
|
||||
start_time = time.time()
|
||||
response = query_engine.query(q)
|
||||
end_time = time.time()
|
||||
|
||||
# Return the query response and source documents
|
||||
print(response.response)
|
||||
|
||||
print("\nSource documents:")
|
||||
for node in response.source_nodes:
|
||||
meta = getattr(node, "metadata", None) or node.node.metadata
|
||||
print(f" {meta.get('file_name')} {getattr(node, 'score', None)}")
|
||||
|
||||
print(f"\nElapsed time: {(end_time-start_time):.1f} seconds")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
5
03-rag/requirements.txt
Normal file
5
03-rag/requirements.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
llama-index-core
|
||||
llama-index-readers-file
|
||||
llama-index-llms-ollama
|
||||
llama-index-embeddings-huggingface
|
||||
python-dateutil
|
||||
Loading…
Add table
Add a link
Reference in a new issue