Skip to content

Commit 66880d4

Browse files
authored
Format code and fix missing arguments (#710)
1 parent 12dd6b2 commit 66880d4

File tree

5 files changed

+14
-25
lines changed

5 files changed

+14
-25
lines changed

examples/search-r1/generate_with_search.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,23 @@
1616
"max_turns": 2,
1717
"topk": 3,
1818
"search_concurrency": 256,
19-
2019
# ============== Search Backend Selection ==============
2120
"search_backend": "local", # Options: "local" or "google"
22-
2321
# ============== Local Search Configuration ==============
2422
# (Only used when search_backend="local")
2523
"local": {
2624
"search_url": "http://127.0.0.1:8000/retrieve", # URL of your local retrieval server
2725
"proxy": None, # Set to your proxy if needed
2826
},
29-
3027
# ============== Google Search Configuration ==============
3128
# (Only used when search_backend="google")
3229
"google": {
3330
"api_key": "your_api_key_here", # Replace with your actual API key
3431
"snippet_only": True, # Set to True to only return snippets
3532
"proxy": None, # Set to your proxy if needed
3633
},
37-
3834
# ============== Log Probability Collection ==============
3935
"return_logprob": True, # Set to True to collect log probabilities for TIS metrics
40-
4136
# ============== Reward Model Configuration ==============
4237
"format_score": 0.2,
4338
}
@@ -90,10 +85,7 @@ async def search(query: str) -> str:
9085
proxy=google_config["proxy"],
9186
)
9287
else:
93-
raise ValueError(
94-
f"Unknown search backend: {backend}. "
95-
f"Must be either 'local' or 'google'."
96-
)
88+
raise ValueError(f"Unknown search backend: {backend}. " f"Must be either 'local' or 'google'.")
9789

9890
return _passages2string(result)
9991

examples/search-r1/local_dense_retriever/retrieval_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,7 @@ def retrieve_endpoint(request: QueryRequest):
355355
request.topk = config.retrieval_topk # fallback to default
356356

357357
# Perform batch retrieval
358-
tmp = retriever.batch_search(
359-
query_list=request.queries, num=request.topk, return_score=request.return_scores
360-
)
358+
tmp = retriever.batch_search(query_list=request.queries, num=request.topk, return_score=request.return_scores)
361359

362360
scores = []
363361
try:
@@ -382,7 +380,10 @@ def retrieve_endpoint(request: QueryRequest):
382380
if __name__ == "__main__":
383381
parser = argparse.ArgumentParser(description="Launch the local faiss retriever.")
384382
parser.add_argument(
385-
"--index_path", type=str, default="/home/peterjin/mnt/index/wiki-18/e5_Flat.index", help="Corpus indexing file."
383+
"--index_path",
384+
type=str,
385+
default="/home/peterjin/mnt/index/wiki-18/e5_Flat.index",
386+
help="Corpus indexing file.",
386387
)
387388
parser.add_argument(
388389
"--corpus_path",

examples/search-r1/local_search_server.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
}
2020
"""
2121

22-
import asyncio
23-
import argparse
24-
from typing import List, Dict, Optional
22+
from typing import Dict, List, Optional
23+
2524
import aiohttp
2625

2726

@@ -55,7 +54,7 @@ async def local_search(
5554
payload = {
5655
"queries": [query],
5756
"topk": top_k,
58-
"return_scores": False # We don't need scores for compatibility with google_search_server
57+
"return_scores": False, # We don't need scores for compatibility with google_search_server
5958
}
6059

6160
# Send async request to local retrieval server
@@ -86,19 +85,15 @@ async def local_search(
8685
# retrieval_server returns: {"document": {"id": "...", "contents": '"Title"\nText...'}}
8786
if isinstance(item, dict):
8887
# Access the document dict first, then get contents
89-
content = item.get('contents', "")
88+
content = item.get("contents", "")
9089

9190
if content:
9291
# The contents are already in the correct format: '"Title"\nText content...'
9392
# Just pass through as-is to match google_search format
94-
contexts.append({
95-
"document": {"contents": content}
96-
})
93+
contexts.append({"document": {"contents": content}})
9794
else:
9895
# Empty content case - provide default values
99-
contexts.append({
100-
"document": {"contents": '"No title."\nNo snippet available.'}
101-
})
96+
contexts.append({"document": {"contents": '"No title."\nNo snippet available.'}})
10297

10398
# If no results found, return empty list (consistent with google_search_server.py)
10499
return contexts

slime/backends/fsdp_utils/arguments.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class FSDPArgs:
2828

2929
# Precision
3030
gradient_checkpointing: bool = False
31+
fp16: bool = False
3132

3233
# FSDP configuration
3334
fsdp_full_params: bool = False # If True, use full_tensor; if False, use shard_tensor

slime/backends/megatron_utils/loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,4 +725,4 @@ def loss_function(
725725
device=logits.device,
726726
),
727727
},
728-
)
728+
)

0 commit comments

Comments
 (0)