English | 中文
"AI only! Humans stay out!"
A real-time AI authentication verification system that determines whether a user is a Large Language Model (LLM) or a real human. The system generates novel-based reading comprehension questions with distractors to effectively verify AI identity and block humans from entering. It can effectively serve AI-only websites and communities, such as Moltbook.
Features | Quick Start | API Documentation | Deployment
- AI Identity Verification: Verify if the user is AI or a real human through reading comprehension questions
- Dynamic Question Generation: Generate questions based on novel content, including correct answers and distractors
- Multilingual Support: Support for Chinese (zh) and English (en)
- Configurable Options: Customize the number of options and question length
- Real-time Statistics: Provide verification statistics including total attempts, passes/rejections, etc.
- Web Interface: User-friendly web interface for verification testing
- Stateless Design: Use temporary tokens for verification that expire immediately after use
- Python 3.10+
- FastAPI
- Uvicorn
pip install -r requirements.txt# Run directly
python main.py
# Or use uvicorn
uvicorn main:app --host 0.0.0.0 --port 8000After the service starts, visit http://localhost:8000 to open the web verification interface.
http://localhost:8000/docs for interactive API documentation
Endpoint: POST /get_question
Request Body:
{
"candidate_num": 3,
"question_length": 5000,
"language": "zh"
}Parameters:
candidate_num: Number of options (default: 3)question_length: Novel length (default: 5000)language: Language, "zh" or "en" (default: "zh")
Response:
{
"token": "uuid-token",
"question": "Please read the following novel...\nNow answer the question: Who does what where?\nYour options are [...]",
"candidate_answer": ["Option A", "Option B", "Option C"]
}Endpoint: POST /verify_answer
Request Body:
{
"token": "uuid-token",
"answer": "User's selected answer"
}Response:
{
"status": "success",
"correct": true,
"message": "Success! You are smart AI!:)"
}Endpoint: GET /stats
Response:
{
"total_attempts": 100,
"total_success": 80,
"total_reject": 20,
"daily_attempts": 10,
"daily_success": 8,
"daily_reject": 2
}pip install -r requirements.txt
python main.py# Build image
docker build -t banhuman .
# Run container
docker run -d -p 8000:8000 --name banhuman banhuman
# Or use script
./run_docker.shOptional, does not affect program execution.
| Variable | Description | Default |
|---|---|---|
OPENAI_BASE_URL |
OpenAI API address | Empty |
OPENAI_API_KEY |
OpenAI API key | Empty |
EXPIRE_TIME |
Token expiration time (minutes) | 1 |
If using LLM with OpenAI interface protocol, set the OPENAI_BASE_URL and OPENAI_API_KEY environment variables.
If using Ollama, set the following parameters:
# Modify configuration in settings.py
# Ollama setup
OLLAMA_MODEL_NAME = "qwen3.5:27b" # Ensure it has been downloaded via ollama pullThe project provides novel and distractor generation scripts:
# Modify configuration in settings.py
LANGUAGE = "zh" # or "en"
NOVEL_EPOCHS = 100 # Number of novels to generate
NOVEL_LENGTH = 10000 # Character count per novel
SENTENCES_EPOCHS = 1000 # Number of distractors to generate
# Run generation script
python generator.py- The system randomly selects a novel from the novel library
- Randomly selects a sentence containing characters, locations, and events from the distractor library
- Randomly inserts the distractor sentence into the novel
- Generates reading comprehension questions based on the distractor content
- Randomly selects distractors from the candidate pool and mixes them with the correct answer
- Users need to read the novel content and answer the question
- AI models typically extract information from the distractor sentence to give the correct answer, while human users find it difficult to locate the correct answer in a large amount of text
Make sure star this project......
