Team Ai
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 21d agoView on Hugging Face
0likes1.2kdownloads
test-simulator.sh87 linesDownload Raw Back to llama-eval
1#!/bin/bash2 3set -e4 5# Get the directory where this script is located6SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"7 8echo "=== llama-server-simulator Test Script ==="9echo ""10 11PORT=803312SUCCESS_RATE=0.813TEST_PORT=803414 15echo "Starting simulator on port $PORT with success rate $SUCCESS_RATE..."16source "$SCRIPT_DIR/venv/bin/activate"17python3 "$SCRIPT_DIR/llama-server-simulator.py" --port $PORT --success-rate $SUCCESS_RATE > /tmp/simulator-test.log 2>&1 &18SIMULATOR_PID=$!19 20echo "Waiting for simulator to start..."21sleep 522 23# Helper function to make a request and extract the answer24make_request() {25  local question="$1"26  curl -s -X POST http://localhost:$PORT/v1/chat/completions \27    -H "Content-Type: application/json" \28    -d "{29      \"model\": \"llama\",30      \"messages\": [31        {\"role\": \"user\", \"content\": \"$question\"}32      ],33      \"temperature\": 0,34      \"max_tokens\": 204835    }" | python3 -c "import sys, json; data = json.load(sys.stdin); print(data.get('choices', [{}])[0].get('message', {}).get('content', data.get('error', 'No response')))"36}37 38# Test question (repeated in multiple tests)39TEST_QUESTION="Quadratic polynomials P(x) and Q(x) have leading coefficients 2 and -2, respectively. The graphs of both polynomials pass through the two points (16,54) and (20,53). Find P(0) + Q(0)."40 41echo ""42echo "=== Test 1: Correct Answer ==="43echo "Sending request with known question..."44answer=$(make_request "$TEST_QUESTION")45echo "Answer: $answer"46echo "Expected: 116"47echo "Correct: $([ "$answer" == "116" ] && echo "Yes" || echo "No")"48 49echo ""50echo "=== Test 2: Wrong Answer ==="51echo "Sending request with known question (success rate 0.0)..."52answer=$(make_request "$TEST_QUESTION")53echo "Answer: $answer"54echo "Expected: 116"55echo "Correct: $([ "$answer" == "116" ] && echo "Yes" || echo "No")"56 57echo ""58echo "=== Test 3: No Matching Question ==="59echo "Sending request with non-matching text..."60response=$(make_request "What is the capital of France?")61echo "Response: $response"62echo "Expected: No matching question found"63echo "Correct: $([ "$response" == "No matching question found" ] && echo "Yes" || echo "No")"64 65echo ""66echo "=== Test 4: Success Rate Verification ==="67echo "Sending 10 requests to test success rate..."68correct_count=069for i in {1..10}; do70  answer=$(make_request "$TEST_QUESTION")71  if [ "$answer" == "116" ]; then72    correct_count=$((correct_count + 1))73  fi74  echo "  Request $i: Answer = $answer"75done76echo "Correct answers: $correct_count/10"77echo "Expected: ~8/10 (80% success rate)"78echo "Success rate: $(echo "scale=1; $correct_count * 10" | bc)%"79 80echo ""81echo "=== Test Complete ==="82echo "Stopping simulator..."83kill $SIMULATOR_PID 2>/dev/null84wait $SIMULATOR_PID 2>/dev/null || true85 86echo "Simulator stopped."87