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
41
04-semantic-search/run_query.sh
Executable file
41
04-semantic-search/run_query.sh
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
# This shell script will handle I/O for the python query engine
|
||||
# It will take a query and return the formatted results
|
||||
|
||||
# E.M.F. August 2025
|
||||
|
||||
# Usage: ./run_query.sh
|
||||
|
||||
QUERY_SCRIPT="query_hybrid.py"
|
||||
VENV_DIR=".venv"
|
||||
|
||||
# Activate the virtual environment
|
||||
if [ -d "$VENV_DIR" ]; then
|
||||
source "$VENV_DIR/bin/activate"
|
||||
echo "Activated virtual environment: $VENV_DIR"
|
||||
else
|
||||
echo "Error: Virtual environment not found at '$VENV_DIR'" >&2
|
||||
echo "Create one with: python3 -m venv $VENV_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "Current query engine is $QUERY_SCRIPT\n"
|
||||
|
||||
# Loop until input is "exit"
|
||||
while true; do
|
||||
read -p "Enter your query (or type 'exit' to quit): " query
|
||||
if [ "$query" == "exit" ] || [ "$query" == "quit" ] || [ "$query" == "" ] ; then
|
||||
echo "Exiting..."
|
||||
break
|
||||
fi
|
||||
time_start=$(date +%s)
|
||||
|
||||
# Call the python script with the query and format the output
|
||||
python3 $QUERY_SCRIPT --query "$query" | \
|
||||
expand | sed -E 's|(.* )(.*/data)|\1./data|' | fold -s -w 131
|
||||
|
||||
time_end=$(date +%s)
|
||||
elapsed=$((time_end - time_start))
|
||||
echo -e "Query processed in $elapsed seconds.\n"
|
||||
echo $query >> query.log
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue