Spaces:
Running
Running
Commit
·
1cc6224
0
Parent(s):
initial commit
Browse files- .DS_Store +0 -0
- .gitattributes +35 -0
- README.md +10 -0
- app.py +131 -0
- chess-pieces.jpeg +0 -0
- model_evaluation.py +171 -0
- output/.DS_Store +0 -0
- output/sentence-transformer-finetuned.zip +3 -0
- output/sentence-transformer-finetuned/1_Pooling/config.json +10 -0
- output/sentence-transformer-finetuned/README.md +89 -0
- output/sentence-transformer-finetuned/config.json +26 -0
- output/sentence-transformer-finetuned/config_sentence_transformers.json +9 -0
- output/sentence-transformer-finetuned/model.safetensors +3 -0
- output/sentence-transformer-finetuned/modules.json +20 -0
- output/sentence-transformer-finetuned/sentence_bert_config.json +4 -0
- output/sentence-transformer-finetuned/special_tokens_map.json +37 -0
- output/sentence-transformer-finetuned/tokenizer.json +0 -0
- output/sentence-transformer-finetuned/tokenizer_config.json +64 -0
- output/sentence-transformer-finetuned/vocab.txt +0 -0
- output_topic_details.txt +0 -0
- requirements.txt +115 -0
- test_dataset.csv +21 -0
- train_dataset.csv +14 -0
- val_dataset.csv +12 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: ChessBot
|
3 |
+
emoji: 💻
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.28.3
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
app.py
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from sentence_transformers import SentenceTransformer, util
|
3 |
+
import openai
|
4 |
+
import os
|
5 |
+
|
6 |
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
7 |
+
|
8 |
+
# Initialize paths and model identifiers for easy configuration and maintenance
|
9 |
+
filename = "output_topic_details.txt" # Path to the file storing chess-specific details
|
10 |
+
retrieval_model_name = 'output/sentence-transformer-finetuned/'
|
11 |
+
|
12 |
+
openai.api_key = os.environ["OPENAI_API_KEY"]
|
13 |
+
|
14 |
+
# Attempt to load the necessary models and provide feedback on success or failure
|
15 |
+
try:
|
16 |
+
retrieval_model = SentenceTransformer(retrieval_model_name)
|
17 |
+
print("Models loaded successfully.")
|
18 |
+
except Exception as e:
|
19 |
+
print(f"Failed to load models: {e}")
|
20 |
+
|
21 |
+
def load_and_preprocess_text(filename):
|
22 |
+
"""
|
23 |
+
Load and preprocess text from a file, removing empty lines and stripping whitespace.
|
24 |
+
"""
|
25 |
+
try:
|
26 |
+
with open(filename, 'r', encoding='utf-8') as file:
|
27 |
+
segments = [line.strip() for line in file if line.strip()]
|
28 |
+
print("Text loaded and preprocessed successfully.")
|
29 |
+
return segments
|
30 |
+
except Exception as e:
|
31 |
+
print(f"Failed to load or preprocess text: {e}")
|
32 |
+
return []
|
33 |
+
|
34 |
+
segments = load_and_preprocess_text(filename)
|
35 |
+
|
36 |
+
def find_relevant_segment(user_query, segments):
|
37 |
+
"""
|
38 |
+
Find the most relevant text segment for a user's query using cosine similarity among sentence embeddings.
|
39 |
+
This version finds the best match based on the content of the query.
|
40 |
+
"""
|
41 |
+
try:
|
42 |
+
# Lowercase the query for better matching
|
43 |
+
lower_query = user_query.lower()
|
44 |
+
|
45 |
+
# Encode the query and the segments
|
46 |
+
query_embedding = retrieval_model.encode(lower_query)
|
47 |
+
segment_embeddings = retrieval_model.encode(segments)
|
48 |
+
|
49 |
+
# Compute cosine similarities between the query and the segments
|
50 |
+
similarities = util.pytorch_cos_sim(query_embedding, segment_embeddings)[0]
|
51 |
+
|
52 |
+
# Find the index of the most similar segment
|
53 |
+
best_idx = similarities.argmax()
|
54 |
+
|
55 |
+
# Return the most relevant segment
|
56 |
+
return segments[best_idx]
|
57 |
+
except Exception as e:
|
58 |
+
print(f"Error in finding relevant segment: {e}")
|
59 |
+
return ""
|
60 |
+
|
61 |
+
def generate_response(user_query, relevant_segment):
|
62 |
+
"""
|
63 |
+
Generate a response emphasizing the bot's capability in providing chess information.
|
64 |
+
"""
|
65 |
+
try:
|
66 |
+
system_message = "You are a chess chatbot specialized in providing information on chess rules, strategies, and terminology."
|
67 |
+
user_message = f"Here's the information on chess: {relevant_segment}"
|
68 |
+
messages = [
|
69 |
+
{"role": "system", "content": system_message},
|
70 |
+
{"role": "user", "content": user_message}
|
71 |
+
]
|
72 |
+
response = openai.ChatCompletion.create(
|
73 |
+
model="gpt-3.5-turbo",
|
74 |
+
messages=messages,
|
75 |
+
max_tokens=150,
|
76 |
+
temperature=0.2,
|
77 |
+
top_p=1,
|
78 |
+
frequency_penalty=0,
|
79 |
+
presence_penalty=0
|
80 |
+
)
|
81 |
+
return response['choices'][0]['message']['content'].strip()
|
82 |
+
except Exception as e:
|
83 |
+
print(f"Error in generating response: {e}")
|
84 |
+
return f"Error in generating response: {e}"
|
85 |
+
|
86 |
+
def query_model(question):
|
87 |
+
"""
|
88 |
+
Process a question, find relevant information, and generate a response.
|
89 |
+
"""
|
90 |
+
if question == "":
|
91 |
+
return "Welcome to ChessBot! Ask me anything about chess rules, strategies, and terminology."
|
92 |
+
relevant_segment = find_relevant_segment(question, segments)
|
93 |
+
if not relevant_segment:
|
94 |
+
return "Could not find specific information. Please refine your question."
|
95 |
+
response = generate_response(question, relevant_segment)
|
96 |
+
return response
|
97 |
+
|
98 |
+
# Define the welcome message and specific topics the chatbot can provide information about
|
99 |
+
welcome_message = """
|
100 |
+
# ♟️ Welcome to ChessBot!
|
101 |
+
|
102 |
+
## Your AI-driven assistant for all chess-related queries. Created by SCHOLAR1, SCHOLAR2, and SCHOLAR3 of the 2024 Kode With Klossy CITY Camp.
|
103 |
+
"""
|
104 |
+
|
105 |
+
topics = """
|
106 |
+
### Feel Free to ask me anything from the topics below!
|
107 |
+
- Chess piece movements
|
108 |
+
- Special moves
|
109 |
+
- Game phases
|
110 |
+
- Common strategies
|
111 |
+
- Chess terminology
|
112 |
+
- Famous games
|
113 |
+
- Chess tactics
|
114 |
+
"""
|
115 |
+
|
116 |
+
# Setup the Gradio Blocks interface with custom layout components
|
117 |
+
with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
|
118 |
+
gr.Markdown(welcome_message) # Display the formatted welcome message
|
119 |
+
with gr.Row():
|
120 |
+
with gr.Column():
|
121 |
+
gr.Markdown(topics) # Show the topics on the left side
|
122 |
+
with gr.Row():
|
123 |
+
with gr.Column():
|
124 |
+
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
125 |
+
answer = gr.Textbox(label="ChessBot Response", placeholder="ChessBot will respond here...", interactive=False, lines=10)
|
126 |
+
submit_button = gr.Button("Submit")
|
127 |
+
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
128 |
+
|
129 |
+
|
130 |
+
# Launch the Gradio app to allow user interaction
|
131 |
+
demo.launch(share=True)
|
chess-pieces.jpeg
ADDED
![]() |
model_evaluation.py
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from datasets import Dataset
|
3 |
+
from transformers import pipeline, GPT2Tokenizer
|
4 |
+
from sentence_transformers import SentenceTransformer, util
|
5 |
+
|
6 |
+
# Define paths and models
|
7 |
+
filename = "output_topic_details.txt"
|
8 |
+
retrieval_model_name = 'output/sentence-transformer-finetuned/' #using a prefine-tuned model
|
9 |
+
gpt2_model_name = "gpt2"
|
10 |
+
csv_file_path = "train_dataset.csv"
|
11 |
+
output_csv_file_path = "updated_train_dataset.csv"
|
12 |
+
val_csv_file_path = "val_dataset.csv"
|
13 |
+
output_val_csv_file_path = "updated_val_csv.csv"
|
14 |
+
|
15 |
+
tokenizer = GPT2Tokenizer.from_pretrained(gpt2_model_name)
|
16 |
+
|
17 |
+
# Initialize models
|
18 |
+
try:
|
19 |
+
retrieval_model = SentenceTransformer(retrieval_model_name)
|
20 |
+
gpt_model = pipeline("text-generation", model=gpt2_model_name)
|
21 |
+
print("Models loaded successfully.")
|
22 |
+
except Exception as e:
|
23 |
+
print(f"Failed to load models: {e}")
|
24 |
+
|
25 |
+
def load_and_preprocess_text(filename):
|
26 |
+
"""
|
27 |
+
Load and preprocess text data from a file.
|
28 |
+
|
29 |
+
Parameters:
|
30 |
+
- filename (str): Path to the text file.
|
31 |
+
|
32 |
+
Returns:
|
33 |
+
- list[str]: A list of preprocessed text segments.
|
34 |
+
"""
|
35 |
+
try:
|
36 |
+
with open(filename, 'r', encoding='utf-8') as file:
|
37 |
+
segments = [line.strip() for line in file if line.strip()]
|
38 |
+
print("Text loaded and preprocessed successfully.")
|
39 |
+
return segments
|
40 |
+
except Exception as e:
|
41 |
+
print(f"Failed to load or preprocess text: {e}")
|
42 |
+
return []
|
43 |
+
|
44 |
+
segments = load_and_preprocess_text(filename)
|
45 |
+
|
46 |
+
def find_relevant_segment(user_query, segments):
|
47 |
+
"""
|
48 |
+
Find the most relevant text segment based on a user query.
|
49 |
+
|
50 |
+
Parameters:
|
51 |
+
- user_query (str): The user's query.
|
52 |
+
- segments (list[str]): List of text segments to search within.
|
53 |
+
|
54 |
+
Returns:
|
55 |
+
- str: The most relevant text segment.
|
56 |
+
"""
|
57 |
+
try:
|
58 |
+
query_embedding = retrieval_model.encode(user_query)
|
59 |
+
segment_embeddings = retrieval_model.encode(segments)
|
60 |
+
similarities = util.pytorch_cos_sim(query_embedding, segment_embeddings)[0]
|
61 |
+
best_idx = similarities.argmax()
|
62 |
+
return segments[best_idx]
|
63 |
+
except Exception as e:
|
64 |
+
print(f"Error finding relevant segment: {e}")
|
65 |
+
return ""
|
66 |
+
|
67 |
+
def generate_response(question):
|
68 |
+
"""
|
69 |
+
Generate a response to a given question by finding a relevant text segment and
|
70 |
+
using it to generate a more complete answer.
|
71 |
+
|
72 |
+
Parameters:
|
73 |
+
- question (str): The user's question.
|
74 |
+
|
75 |
+
Returns:
|
76 |
+
- str: Generated response.
|
77 |
+
"""
|
78 |
+
relevant_segment = find_relevant_segment(question, segments)
|
79 |
+
return generate_response_with_context(question, relevant_segment)
|
80 |
+
|
81 |
+
def generate_response_with_context(user_query, relevant_segment):
|
82 |
+
"""
|
83 |
+
Generate a response based on a user query and a relevant segment.
|
84 |
+
|
85 |
+
Parameters:
|
86 |
+
- user_query (str): The user's query.
|
87 |
+
- relevant_segment (str): A relevant fact or detail.
|
88 |
+
|
89 |
+
Returns:
|
90 |
+
- str: Formatted response incorporating the relevant segment.
|
91 |
+
"""
|
92 |
+
try:
|
93 |
+
prompt = f"Thank you for your question! Here is an additional fact about your topic: {relevant_segment}"
|
94 |
+
max_tokens = len(tokenizer(prompt)['input_ids']) + 50
|
95 |
+
response = gpt_model(prompt, max_length=max_tokens, temperature=0.25)[0]['generated_text']
|
96 |
+
return clean_up_response(response, relevant_segment)
|
97 |
+
except Exception as e:
|
98 |
+
print(f"Error generating response: {e}")
|
99 |
+
return ""
|
100 |
+
|
101 |
+
def clean_up_response(response, segment):
|
102 |
+
"""
|
103 |
+
Clean up the generated response to ensure it is tidy and presentable.
|
104 |
+
|
105 |
+
Parameters:
|
106 |
+
- response (str): The initial response generated by the model.
|
107 |
+
- segment (str): The segment used to generate the response.
|
108 |
+
|
109 |
+
Returns:
|
110 |
+
- str: A cleaned and formatted response.
|
111 |
+
"""
|
112 |
+
sentences = response.split('.')
|
113 |
+
cleaned_sentences = [sentence.strip() for sentence in sentences if sentence.strip() and sentence.strip() not in segment]
|
114 |
+
cleaned_response = '. '.join(cleaned_sentences).strip()
|
115 |
+
if cleaned_response and not cleaned_response.endswith((".", "!", "?")):
|
116 |
+
cleaned_response += "."
|
117 |
+
return cleaned_response
|
118 |
+
|
119 |
+
def process_dataset(csv_file_path, output_csv_file_path):
|
120 |
+
"""
|
121 |
+
Process the dataset by generating responses and evaluating their similarities.
|
122 |
+
|
123 |
+
Parameters:
|
124 |
+
- csv_file_path (str): Path to the CSV file containing the dataset.
|
125 |
+
- output_csv_file_path (str): Path where the updated dataset will be saved.
|
126 |
+
|
127 |
+
Prints:
|
128 |
+
- Path to the saved results and the average similarity score.
|
129 |
+
"""
|
130 |
+
df = pd.read_csv(csv_file_path)
|
131 |
+
dataset = Dataset.from_pandas(df)
|
132 |
+
updated_dataset = add_model_answers(dataset)
|
133 |
+
similarities = evaluate_similarity(updated_dataset)
|
134 |
+
updated_dataset = updated_dataset.add_column("similarity", similarities)
|
135 |
+
results_df = updated_dataset.to_pandas()
|
136 |
+
results_df.to_csv(output_csv_file_path, index=False)
|
137 |
+
average_similarity = sum(similarities) / len(similarities) if similarities else 0
|
138 |
+
print(f"Results saved to {output_csv_file_path}")
|
139 |
+
print(f"Average Similarity Score: {average_similarity:.3f}")
|
140 |
+
|
141 |
+
def add_model_answers(dataset):
|
142 |
+
"""
|
143 |
+
Add generated answers to the dataset.
|
144 |
+
|
145 |
+
Parameters:
|
146 |
+
- dataset (datasets.Dataset): The Hugging Face dataset object.
|
147 |
+
|
148 |
+
Returns:
|
149 |
+
- datasets.Dataset: Updated dataset with added answers.
|
150 |
+
"""
|
151 |
+
answers = [generate_response(q) for q in dataset['Question']]
|
152 |
+
dataset = dataset.add_column("Answer", answers)
|
153 |
+
return dataset
|
154 |
+
|
155 |
+
def evaluate_similarity(dataset):
|
156 |
+
"""
|
157 |
+
Evaluate the similarity of generated answers against ground truth answers.
|
158 |
+
|
159 |
+
Parameters:
|
160 |
+
- dataset (datasets.Dataset): The dataset containing both answers and ground truths.
|
161 |
+
|
162 |
+
Returns:
|
163 |
+
- list[float]: List of similarity scores.
|
164 |
+
"""
|
165 |
+
similarities = [util.pytorch_cos_sim(retrieval_model.encode(ans), retrieval_model.encode(gt))[0][0].item()
|
166 |
+
for ans, gt in zip(dataset['Answer'], dataset['GroundTruth'])]
|
167 |
+
return similarities
|
168 |
+
|
169 |
+
# Process datasets
|
170 |
+
process_dataset(csv_file_path, output_csv_file_path)
|
171 |
+
process_dataset(val_csv_file_path, output_val_csv_file_path)
|
output/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
output/sentence-transformer-finetuned.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f96b8ce2ece5d1c766d1169b278147d4f509326274d50725663061b7c4e0c5d3
|
3 |
+
size 83608461
|
output/sentence-transformer-finetuned/1_Pooling/config.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 384,
|
3 |
+
"pooling_mode_cls_token": false,
|
4 |
+
"pooling_mode_mean_tokens": true,
|
5 |
+
"pooling_mode_max_tokens": false,
|
6 |
+
"pooling_mode_mean_sqrt_len_tokens": false,
|
7 |
+
"pooling_mode_weightedmean_tokens": false,
|
8 |
+
"pooling_mode_lasttoken": false,
|
9 |
+
"include_prompt": true
|
10 |
+
}
|
output/sentence-transformer-finetuned/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: sentence-transformers
|
3 |
+
pipeline_tag: sentence-similarity
|
4 |
+
tags:
|
5 |
+
- sentence-transformers
|
6 |
+
- feature-extraction
|
7 |
+
- sentence-similarity
|
8 |
+
|
9 |
+
---
|
10 |
+
|
11 |
+
# {MODEL_NAME}
|
12 |
+
|
13 |
+
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
|
14 |
+
|
15 |
+
<!--- Describe your model here -->
|
16 |
+
|
17 |
+
## Usage (Sentence-Transformers)
|
18 |
+
|
19 |
+
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
20 |
+
|
21 |
+
```
|
22 |
+
pip install -U sentence-transformers
|
23 |
+
```
|
24 |
+
|
25 |
+
Then you can use the model like this:
|
26 |
+
|
27 |
+
```python
|
28 |
+
from sentence_transformers import SentenceTransformer
|
29 |
+
sentences = ["This is an example sentence", "Each sentence is converted"]
|
30 |
+
|
31 |
+
model = SentenceTransformer('{MODEL_NAME}')
|
32 |
+
embeddings = model.encode(sentences)
|
33 |
+
print(embeddings)
|
34 |
+
```
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
## Evaluation Results
|
39 |
+
|
40 |
+
<!--- Describe how your model was evaluated -->
|
41 |
+
|
42 |
+
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
|
43 |
+
|
44 |
+
|
45 |
+
## Training
|
46 |
+
The model was trained with the parameters:
|
47 |
+
|
48 |
+
**DataLoader**:
|
49 |
+
|
50 |
+
`torch.utils.data.dataloader.DataLoader` of length 51 with parameters:
|
51 |
+
```
|
52 |
+
{'batch_size': 16, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
|
53 |
+
```
|
54 |
+
|
55 |
+
**Loss**:
|
56 |
+
|
57 |
+
`sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
|
58 |
+
|
59 |
+
Parameters of the fit()-Method:
|
60 |
+
```
|
61 |
+
{
|
62 |
+
"epochs": 4,
|
63 |
+
"evaluation_steps": 0,
|
64 |
+
"evaluator": "NoneType",
|
65 |
+
"max_grad_norm": 1,
|
66 |
+
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
|
67 |
+
"optimizer_params": {
|
68 |
+
"lr": 2e-05
|
69 |
+
},
|
70 |
+
"scheduler": "WarmupLinear",
|
71 |
+
"steps_per_epoch": null,
|
72 |
+
"warmup_steps": 100,
|
73 |
+
"weight_decay": 0.01
|
74 |
+
}
|
75 |
+
```
|
76 |
+
|
77 |
+
|
78 |
+
## Full Model Architecture
|
79 |
+
```
|
80 |
+
SentenceTransformer(
|
81 |
+
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
|
82 |
+
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
83 |
+
(2): Normalize()
|
84 |
+
)
|
85 |
+
```
|
86 |
+
|
87 |
+
## Citing & Authors
|
88 |
+
|
89 |
+
<!--- Describe where people can find more information -->
|
output/sentence-transformer-finetuned/config.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "sentence-transformers/all-MiniLM-L6-v2",
|
3 |
+
"architectures": [
|
4 |
+
"BertModel"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"classifier_dropout": null,
|
8 |
+
"gradient_checkpointing": false,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 384,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 1536,
|
14 |
+
"layer_norm_eps": 1e-12,
|
15 |
+
"max_position_embeddings": 512,
|
16 |
+
"model_type": "bert",
|
17 |
+
"num_attention_heads": 12,
|
18 |
+
"num_hidden_layers": 6,
|
19 |
+
"pad_token_id": 0,
|
20 |
+
"position_embedding_type": "absolute",
|
21 |
+
"torch_dtype": "float32",
|
22 |
+
"transformers_version": "4.39.3",
|
23 |
+
"type_vocab_size": 2,
|
24 |
+
"use_cache": true,
|
25 |
+
"vocab_size": 30522
|
26 |
+
}
|
output/sentence-transformer-finetuned/config_sentence_transformers.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "2.0.0",
|
4 |
+
"transformers": "4.6.1",
|
5 |
+
"pytorch": "1.8.1"
|
6 |
+
},
|
7 |
+
"prompts": {},
|
8 |
+
"default_prompt_name": null
|
9 |
+
}
|
output/sentence-transformer-finetuned/model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6e55e6c6bb6150eed6b877a2ae6a897cfcfe236c6395cee0e7f5b952541954cf
|
3 |
+
size 90864192
|
output/sentence-transformer-finetuned/modules.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"idx": 0,
|
4 |
+
"name": "0",
|
5 |
+
"path": "",
|
6 |
+
"type": "sentence_transformers.models.Transformer"
|
7 |
+
},
|
8 |
+
{
|
9 |
+
"idx": 1,
|
10 |
+
"name": "1",
|
11 |
+
"path": "1_Pooling",
|
12 |
+
"type": "sentence_transformers.models.Pooling"
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"idx": 2,
|
16 |
+
"name": "2",
|
17 |
+
"path": "2_Normalize",
|
18 |
+
"type": "sentence_transformers.models.Normalize"
|
19 |
+
}
|
20 |
+
]
|
output/sentence-transformer-finetuned/sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 256,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
output/sentence-transformer-finetuned/special_tokens_map.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": {
|
3 |
+
"content": "[CLS]",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"mask_token": {
|
10 |
+
"content": "[MASK]",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": {
|
17 |
+
"content": "[PAD]",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"sep_token": {
|
24 |
+
"content": "[SEP]",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"unk_token": {
|
31 |
+
"content": "[UNK]",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": false,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
}
|
37 |
+
}
|
output/sentence-transformer-finetuned/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
output/sentence-transformer-finetuned/tokenizer_config.json
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "[PAD]",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"100": {
|
12 |
+
"content": "[UNK]",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"101": {
|
20 |
+
"content": "[CLS]",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
},
|
27 |
+
"102": {
|
28 |
+
"content": "[SEP]",
|
29 |
+
"lstrip": false,
|
30 |
+
"normalized": false,
|
31 |
+
"rstrip": false,
|
32 |
+
"single_word": false,
|
33 |
+
"special": true
|
34 |
+
},
|
35 |
+
"103": {
|
36 |
+
"content": "[MASK]",
|
37 |
+
"lstrip": false,
|
38 |
+
"normalized": false,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false,
|
41 |
+
"special": true
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"clean_up_tokenization_spaces": true,
|
45 |
+
"cls_token": "[CLS]",
|
46 |
+
"do_basic_tokenize": true,
|
47 |
+
"do_lower_case": true,
|
48 |
+
"mask_token": "[MASK]",
|
49 |
+
"max_length": 128,
|
50 |
+
"model_max_length": 512,
|
51 |
+
"never_split": null,
|
52 |
+
"pad_to_multiple_of": null,
|
53 |
+
"pad_token": "[PAD]",
|
54 |
+
"pad_token_type_id": 0,
|
55 |
+
"padding_side": "right",
|
56 |
+
"sep_token": "[SEP]",
|
57 |
+
"stride": 0,
|
58 |
+
"strip_accents": null,
|
59 |
+
"tokenize_chinese_chars": true,
|
60 |
+
"tokenizer_class": "BertTokenizer",
|
61 |
+
"truncation_side": "right",
|
62 |
+
"truncation_strategy": "longest_first",
|
63 |
+
"unk_token": "[UNK]"
|
64 |
+
}
|
output/sentence-transformer-finetuned/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
output_topic_details.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
requirements.txt
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
accelerate==0.29.2
|
2 |
+
aiofiles==23.2.1
|
3 |
+
aiohttp==3.9.4
|
4 |
+
aiosignal==1.3.1
|
5 |
+
altair==5.3.0
|
6 |
+
annotated-types==0.6.0
|
7 |
+
anyio==4.3.0
|
8 |
+
appnope==0.1.4
|
9 |
+
asttokens==2.4.1
|
10 |
+
attrs==23.2.0
|
11 |
+
certifi==2024.2.2
|
12 |
+
charset-normalizer==3.3.2
|
13 |
+
click==8.1.7
|
14 |
+
comm==0.2.2
|
15 |
+
contourpy==1.2.1
|
16 |
+
cycler==0.12.1
|
17 |
+
datasets==2.18.0
|
18 |
+
debugpy==1.8.1
|
19 |
+
decorator==5.1.1
|
20 |
+
dill==0.3.8
|
21 |
+
executing==2.0.1
|
22 |
+
fastapi==0.110.1
|
23 |
+
ffmpy==0.3.2
|
24 |
+
filelock==3.13.4
|
25 |
+
fonttools==4.51.0
|
26 |
+
frozenlist==1.4.1
|
27 |
+
fsspec==2024.2.0
|
28 |
+
gradio==4.26.0
|
29 |
+
gradio_client==0.15.1
|
30 |
+
h11==0.14.0
|
31 |
+
httpcore==1.0.5
|
32 |
+
httpx==0.27.0
|
33 |
+
huggingface-hub==0.22.2
|
34 |
+
idna==3.7
|
35 |
+
importlib_resources==6.4.0
|
36 |
+
ipykernel==6.29.4
|
37 |
+
ipython==8.23.0
|
38 |
+
jedi==0.19.1
|
39 |
+
Jinja2==3.1.3
|
40 |
+
joblib==1.4.0
|
41 |
+
jsonschema==4.21.1
|
42 |
+
jsonschema-specifications==2023.12.1
|
43 |
+
jupyter_client==8.6.1
|
44 |
+
jupyter_core==5.7.2
|
45 |
+
kiwisolver==1.4.5
|
46 |
+
markdown-it-py==3.0.0
|
47 |
+
MarkupSafe==2.1.5
|
48 |
+
matplotlib==3.8.4
|
49 |
+
matplotlib-inline==0.1.6
|
50 |
+
mdurl==0.1.2
|
51 |
+
mpmath==1.3.0
|
52 |
+
multidict==6.0.5
|
53 |
+
multiprocess==0.70.16
|
54 |
+
nest-asyncio==1.6.0
|
55 |
+
networkx==3.3
|
56 |
+
numpy==1.26.4
|
57 |
+
orjson==3.10.0
|
58 |
+
packaging==24.0
|
59 |
+
pandas==2.2.2
|
60 |
+
parso==0.8.4
|
61 |
+
pexpect==4.9.0
|
62 |
+
pillow==10.3.0
|
63 |
+
platformdirs==4.2.0
|
64 |
+
prompt-toolkit==3.0.43
|
65 |
+
psutil==5.9.8
|
66 |
+
ptyprocess==0.7.0
|
67 |
+
pure-eval==0.2.2
|
68 |
+
pyarrow==15.0.2
|
69 |
+
pyarrow-hotfix==0.6
|
70 |
+
pydantic==2.7.0
|
71 |
+
pydantic_core==2.18.1
|
72 |
+
pydub==0.25.1
|
73 |
+
Pygments==2.17.2
|
74 |
+
pyparsing==3.1.2
|
75 |
+
python-dateutil==2.9.0.post0
|
76 |
+
python-multipart==0.0.9
|
77 |
+
pytz==2024.1
|
78 |
+
PyYAML==6.0.1
|
79 |
+
pyzmq==25.1.2
|
80 |
+
referencing==0.34.0
|
81 |
+
regex==2023.12.25
|
82 |
+
requests==2.31.0
|
83 |
+
rich==13.7.1
|
84 |
+
rpds-py==0.18.0
|
85 |
+
ruff==0.3.7
|
86 |
+
safetensors==0.4.2
|
87 |
+
scikit-learn==1.4.2
|
88 |
+
scipy==1.13.0
|
89 |
+
semantic-version==2.10.0
|
90 |
+
sentence-transformers==2.6.1
|
91 |
+
shellingham==1.5.4
|
92 |
+
six==1.16.0
|
93 |
+
sniffio==1.3.1
|
94 |
+
stack-data==0.6.3
|
95 |
+
starlette==0.37.2
|
96 |
+
sympy==1.12
|
97 |
+
threadpoolctl==3.4.0
|
98 |
+
tokenizers==0.15.2
|
99 |
+
tomlkit==0.12.0
|
100 |
+
toolz==0.12.1
|
101 |
+
torch==2.2.2
|
102 |
+
tornado==6.4
|
103 |
+
tqdm==4.66.2
|
104 |
+
traitlets==5.14.2
|
105 |
+
transformers==4.39.3
|
106 |
+
typer==0.12.3
|
107 |
+
typing_extensions==4.11.0
|
108 |
+
tzdata==2024.1
|
109 |
+
urllib3==2.2.1
|
110 |
+
uvicorn==0.29.0
|
111 |
+
wcwidth==0.2.13
|
112 |
+
websockets==11.0.3
|
113 |
+
xxhash==3.4.1
|
114 |
+
yarl==1.9.4
|
115 |
+
openai==0.28
|
test_dataset.csv
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Question,GroundTruth
|
2 |
+
How does a pawn move in chess?,"A pawn moves forward one square, but it captures diagonally. On its first move, a pawn can move forward two squares."
|
3 |
+
What are the basic moves of a king in chess?,"The king moves one square in any direction: horizontally, vertically, or diagonally."
|
4 |
+
How does a knight move in chess?,"The knight moves in an L-shape: two squares in one direction and then one square perpendicular, or one square in one direction and then two squares perpendicular."
|
5 |
+
What is castling in chess?,"Castling is a move that involves the king moving two squares towards a rook on the player's first rank, then the rook moving to the square over which the king crossed."
|
6 |
+
What is a check in chess?,"A check is a situation where a king is under threat of being captured on the next move."
|
7 |
+
How do you win a game of chess?,"A game of chess is won by checkmating your opponent's king, which means the king is in a position to be captured and cannot escape."
|
8 |
+
What is a stalemate in chess?,"A stalemate occurs when the player whose turn it is to move has no legal move and their king is not in check. It results in a draw."
|
9 |
+
What is en passant in chess?,"En passant is a special pawn capture that can occur if a pawn moves two squares forward from its starting position and lands beside an opponent's pawn."
|
10 |
+
What is the purpose of a chess clock?,"A chess clock is used to track the total time each player takes for their moves. If a player's time runs out, they lose the game."
|
11 |
+
What is a fork in chess?,"A fork is a tactic where a single piece attacks two or more of the opponent's pieces at the same time."
|
12 |
+
How does a bishop move in chess?,"A bishop moves diagonally any number of squares, but cannot jump over other pieces."
|
13 |
+
What is a pin in chess?,"A pin occurs when a piece cannot move without exposing a more valuable piece, like the king or queen, to attack."
|
14 |
+
What is a discovered check in chess?,"A discovered check happens when a piece moves, revealing an attack on the opponent's king by another piece."
|
15 |
+
How does a rook move in chess?,"A rook moves any number of squares along a row or column."
|
16 |
+
What is a gambit in chess?,"A gambit is a chess opening in which a player sacrifices material, usually a pawn, with the hope of achieving a subsequent advantageous position."
|
17 |
+
What is the fifty-move rule in chess?,"The fifty-move rule allows a player to claim a draw if no pawn has been moved and no capture has been made in the last fifty moves by each player."
|
18 |
+
What is the difference between check and checkmate?,"Check is when the king is in danger but can still escape, whereas checkmate is when the king is in danger and cannot escape."
|
19 |
+
How does a queen move in chess?,"The queen can move any number of squares along a row, column, or diagonal."
|
20 |
+
What is a perpetual check in chess?,"Perpetual check is a situation in which one player can check the opponent's king continuously, resulting in a draw if it occurs three times."
|
21 |
+
What are the three phases of a chess game?,"The three phases of a chess game are the opening, the middlegame, and the endgame."
|
train_dataset.csv
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Question,GroundTruth
|
2 |
+
What is the best opening move for white?,"The best opening move for white is often considered to be 1. e4, aiming to control the center and open lines for the queen and bishop."
|
3 |
+
What are the common responses to 1. e4?,"Common responses to 1. e4 include 1... e5, 1... c5 (Sicilian Defense), 1... e6 (French Defense), and 1... c6 (Caro-Kann Defense)."
|
4 |
+
How do I play the Sicilian Defense?,"To play the Sicilian Defense, respond to 1. e4 with 1... c5, aiming to challenge white's control of the center and create an asymmetrical pawn structure."
|
5 |
+
What is a good strategy for the middle game?,"A good strategy for the middle game includes developing your pieces to active squares, controlling the center, coordinating your pieces for potential attacks, and ensuring king safety."
|
6 |
+
How can I effectively coordinate an attack?,"To effectively coordinate an attack, focus on piece activity, look for weaknesses in your opponent's position, and try to double your rooks or align them with your queen for combined threats."
|
7 |
+
What should I focus on in the endgame?,"In the endgame, focus on king activity, promoting pawns, and creating passed pawns. It's crucial to centralize your king and use it actively in the fight."
|
8 |
+
How do I achieve a checkmate with a king and rook against a lone king?,"To achieve checkmate with a king and rook against a lone king, force the opposing king to the edge of the board and use your king and rook to create a checkmate pattern, often referred to as the 'box' method."
|
9 |
+
What is the Lucena position?,"The Lucena position is a winning technique in rook endgames where the stronger side's king is cut off by a file, and the winning side uses the rook to build a 'bridge' for the king to support the promotion of a pawn."
|
10 |
+
How do I play the Philidor position?,"The Philidor position is a defensive technique in rook endgames where the defender places the rook on the third rank, preventing the opposing king from advancing and thus creating a draw by maintaining the position."
|
11 |
+
What is a pin in chess?,"A pin in chess is a tactic where a piece cannot move without exposing a more valuable piece behind it to capture. Pins can be absolute, where the pinned piece is in front of the king, or relative, involving other pieces."
|
12 |
+
How do I use a fork in chess?,"A fork is a tactic where a single piece, often a knight, attacks two or more of the opponent's pieces simultaneously, creating a scenario where the opponent cannot defend both pieces effectively."
|
13 |
+
How can I improve my chess rating?,"To improve your chess rating, study opening theory, practice middle game tactics, and learn endgame techniques. Regularly playing games, analyzing your losses, and solving chess puzzles can also help improve your skills."
|
14 |
+
What resources are good for learning chess?,"Good resources for learning chess include online platforms like Chess.com and Lichess.org, books such as 'My System' by Aron Nimzowitsch and 'Chess Fundamentals' by José Capablanca, and video lessons from experienced players."
|
val_dataset.csv
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Question,GroundTruth
|
2 |
+
What are the rules for castling in chess?,"Castling is a special move in chess that involves the king and one of the rooks. The king moves two squares towards the rook, and the rook moves to the square next to the king. Certain conditions must be met: neither the king nor the rook involved has previously moved, there are no pieces between the king and the rook, the king is not in check, and the squares the king moves across are not under attack."
|
3 |
+
How does en passant work in chess?,"En passant is a special pawn capture in chess. It occurs when a pawn moves two squares forward from its starting position and lands beside an opponent's pawn. The opponent's pawn can capture the moving pawn as if it had moved only one square. This capture must be made immediately on the next move."
|
4 |
+
What is the purpose of a pawn promotion?,"Pawn promotion occurs when a pawn reaches the farthest rank from its starting position. The pawn can then be promoted to any other piece, except a king, typically a queen. This is to reward the player for advancing the pawn so far across the board, significantly increasing the material advantage."
|
5 |
+
Can you explain stalemate in chess?,"A stalemate in chess occurs when a player has no legal moves and their king is not in check. This situation results in a draw. It often happens in endgames when one side has few pieces left and is unable to make a legal move without placing their king in check."
|
6 |
+
What constitutes checkmate in chess?,"Checkmate occurs when a player's king is in a position to be captured (in check) and there is no legal move to remove the threat of capture. This results in a win for the player delivering the checkmate."
|
7 |
+
How does the fifty-move rule work in chess?,"The fifty-move rule in chess allows a player to claim a draw if no pawn movement or capture has been made in the last fifty moves by either player. This rule is intended to prevent endlessly drawn-out games."
|
8 |
+
What is the basic strategy for the opening phase in chess?,"In the opening phase of chess, the basic strategy includes controlling the center of the board, developing your pieces (knights and bishops), and ensuring the king's safety, usually by castling. Developing pawns and pieces to active squares helps in controlling the game from the start."
|
9 |
+
How do you perform a fork in chess?,"A fork in chess is a tactic where a single piece makes two or more direct attacks simultaneously. Knights are particularly effective at forking because they can attack pieces in different directions that are not aligned. Other pieces can also fork by targeting multiple high-value pieces at once."
|
10 |
+
What is a pin in chess?,"A pin in chess is a tactic where a piece cannot move without exposing a more valuable piece behind it to capture. For example, a bishop can pin a knight to a king if moving the knight would place the king in check."
|
11 |
+
Explain the concept of zugzwang in chess?,"Zugzwang is a situation in chess where a player is put at a disadvantage because they must make a move, even though any move will worsen their position. It often occurs in endgames, where any move a player makes will lead to a weaker position or a loss."
|
12 |
+
|