flashrag-dev 0.1.4.dev20241208__tar.gz → 0.1.4.dev20241214__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flashrag-dev-0.1.4.dev20241208/flashrag_dev.egg-info → flashrag-dev-0.1.4.dev20241214}/PKG-INFO +1 -1
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/config/config.py +12 -5
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/generator.py +42 -37
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/__init__.py +1 -1
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/active_pipeline.py +5 -8
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/prompt/base_prompt.py +2 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/retriever.py +1 -1
- flashrag-dev-0.1.4.dev20241214/flashrag/version.py +1 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214/flashrag_dev.egg-info}/PKG-INFO +1 -1
- flashrag-dev-0.1.4.dev20241208/flashrag/version.py +0 -1
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/LICENSE +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/README.md +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/config/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/config/basic_config.yaml +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/dataset/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/dataset/dataset.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/dataset/utils.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/_bleu.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/evaluator.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/metrics.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/utils.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/fid.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/openai_generator.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/stop_word_criteria.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/utils.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/judger/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/judger/judger.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/branching_pipeline.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/pipeline.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/replug_utils.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/prompt/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/prompt/selfask_examplars.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/prompt/trace_examplars.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/kg_refiner.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/llmlingua_compressor.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/refiner.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/selective_context_compressor.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/__main__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/encoder.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/index_builder.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/reranker.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/utils.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/utils/__init__.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/utils/constants.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/utils/pred_parse.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/utils/utils.py +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag_dev.egg-info/SOURCES.txt +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag_dev.egg-info/dependency_links.txt +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag_dev.egg-info/requires.txt +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag_dev.egg-info/top_level.txt +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/pyproject.toml +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/setup.cfg +0 -0
- {flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/setup.py +0 -0
{flashrag-dev-0.1.4.dev20241208/flashrag_dev.egg-info → flashrag-dev-0.1.4.dev20241214}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flashrag-dev
|
|
3
|
-
Version: 0.1.4.
|
|
3
|
+
Version: 0.1.4.dev20241214
|
|
4
4
|
Summary: A library for efficient Retrieval-Augmented Generation research
|
|
5
5
|
Home-page: https://github.com/RUC-NLPIR/FlashRAG
|
|
6
6
|
Author: Jiajie Jin, Yutao Zhu, Chenghao Zhang, Xinyu Yang, Zhicheng Dou
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import os
|
|
3
|
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
3
4
|
import yaml
|
|
4
5
|
import random
|
|
5
6
|
import datetime
|
|
@@ -102,13 +103,19 @@ class Config:
|
|
|
102
103
|
gpu_id = self.final_config["gpu_id"]
|
|
103
104
|
if gpu_id is not None:
|
|
104
105
|
os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id)
|
|
106
|
+
try:
|
|
107
|
+
# import pynvml
|
|
108
|
+
# pynvml.nvmlInit()
|
|
109
|
+
# gpu_num = pynvml.nvmlDeviceGetCount()
|
|
105
110
|
import torch
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
gpu_num = torch.cuda.device_count()
|
|
112
|
+
except:
|
|
113
|
+
gpu_num = 0
|
|
114
|
+
self.final_config['gpu_num'] = gpu_num
|
|
115
|
+
if gpu_num > 0:
|
|
116
|
+
self.final_config["device"] = "cuda"
|
|
108
117
|
else:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
self.final_config["device"] = torch.device("cpu")
|
|
118
|
+
self.final_config['device'] = 'cpu'
|
|
112
119
|
|
|
113
120
|
def _set_additional_key(self):
|
|
114
121
|
# set dataset
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/generator.py
RENAMED
|
@@ -4,7 +4,6 @@ import warnings
|
|
|
4
4
|
from tqdm import tqdm
|
|
5
5
|
from tqdm.auto import trange
|
|
6
6
|
import numpy as np
|
|
7
|
-
import torch
|
|
8
7
|
from transformers import (
|
|
9
8
|
AutoTokenizer,
|
|
10
9
|
AutoModelForCausalLM,
|
|
@@ -25,7 +24,7 @@ class BaseGenerator:
|
|
|
25
24
|
self.max_input_len = config["generator_max_input_len"]
|
|
26
25
|
self.batch_size = config["generator_batch_size"]
|
|
27
26
|
self.device = config["device"]
|
|
28
|
-
self.gpu_num =
|
|
27
|
+
self.gpu_num = config['gpu_num']
|
|
29
28
|
self.config = config
|
|
30
29
|
self.generation_params = config["generation_params"]
|
|
31
30
|
|
|
@@ -64,6 +63,7 @@ class EncoderDecoderGenerator(BaseGenerator):
|
|
|
64
63
|
self.tokenizer = AutoTokenizer.from_pretrained(self.model_path)
|
|
65
64
|
|
|
66
65
|
def encode_passages(self, batch_text_passages: List[List[str]]):
|
|
66
|
+
import torch
|
|
67
67
|
# need size: [batch_size, passage_num, passage_len]
|
|
68
68
|
passage_ids, passage_masks = [], []
|
|
69
69
|
for text_passages in batch_text_passages:
|
|
@@ -81,7 +81,6 @@ class EncoderDecoderGenerator(BaseGenerator):
|
|
|
81
81
|
passage_masks = torch.cat(passage_masks, dim=0)
|
|
82
82
|
return passage_ids, passage_masks.bool()
|
|
83
83
|
|
|
84
|
-
@torch.inference_mode(mode=True)
|
|
85
84
|
def generate(self, input_list: List, batch_size=None, **params):
|
|
86
85
|
if isinstance(input_list, str):
|
|
87
86
|
input_list = [input_list]
|
|
@@ -128,15 +127,17 @@ class EncoderDecoderGenerator(BaseGenerator):
|
|
|
128
127
|
).to(self.device)
|
|
129
128
|
|
|
130
129
|
# TODO: multi-gpu inference
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
import torch
|
|
131
|
+
with torch.inference_mode():
|
|
132
|
+
if self.fid:
|
|
133
|
+
if 'max_new_tokens' in generation_params:
|
|
134
|
+
max_new_tokens = generation_params.pop('max_new_tokens')
|
|
135
|
+
else:
|
|
136
|
+
max_new_tokens = 32
|
|
137
|
+
|
|
138
|
+
outputs = self.model.generate(**inputs, max_new_tokens=max_new_tokens, pad_token_id=self.tokenizer.pad_token_id, decoder_start_token_id=self.tokenizer.pad_token_id)
|
|
134
139
|
else:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
outputs = self.model.generate(**inputs, max_new_tokens=max_new_tokens, pad_token_id=self.tokenizer.pad_token_id, decoder_start_token_id=self.tokenizer.pad_token_id)
|
|
138
|
-
else:
|
|
139
|
-
outputs = self.model.generate(**inputs, **generation_params)
|
|
140
|
+
outputs = self.model.generate(**inputs, **generation_params)
|
|
140
141
|
outputs = self.tokenizer.batch_decode(
|
|
141
142
|
outputs,
|
|
142
143
|
skip_special_tokens=True,
|
|
@@ -153,9 +154,8 @@ class VLLMGenerator(BaseGenerator):
|
|
|
153
154
|
|
|
154
155
|
def __init__(self, config):
|
|
155
156
|
super().__init__(config)
|
|
156
|
-
|
|
157
|
+
|
|
157
158
|
from vllm import LLM
|
|
158
|
-
|
|
159
159
|
if "gpu_memory_utilization" not in config:
|
|
160
160
|
gpu_memory_utilization = 0.85
|
|
161
161
|
else:
|
|
@@ -187,7 +187,6 @@ class VLLMGenerator(BaseGenerator):
|
|
|
187
187
|
)
|
|
188
188
|
self.tokenizer = AutoTokenizer.from_pretrained(self.model_path, trust_remote_code=True)
|
|
189
189
|
|
|
190
|
-
@torch.inference_mode(mode=True)
|
|
191
190
|
def generate(
|
|
192
191
|
self,
|
|
193
192
|
input_list: List[str],
|
|
@@ -283,6 +282,7 @@ class HFCausalLMGenerator(BaseGenerator):
|
|
|
283
282
|
return model, tokenizer
|
|
284
283
|
|
|
285
284
|
def add_new_tokens(self, token_embedding_path, token_name_func=lambda idx: f"[ref{idx+1}]"):
|
|
285
|
+
import torch
|
|
286
286
|
del self.model
|
|
287
287
|
self.model = AutoModelForCausalLM.from_pretrained(
|
|
288
288
|
self.model_path,
|
|
@@ -318,7 +318,6 @@ class HFCausalLMGenerator(BaseGenerator):
|
|
|
318
318
|
self.model.eval()
|
|
319
319
|
self.model.cuda()
|
|
320
320
|
|
|
321
|
-
@torch.inference_mode(mode=True)
|
|
322
321
|
def generate(
|
|
323
322
|
self,
|
|
324
323
|
input_list: List[str],
|
|
@@ -370,28 +369,30 @@ class HFCausalLMGenerator(BaseGenerator):
|
|
|
370
369
|
generated_token_ids = []
|
|
371
370
|
generated_token_logits = []
|
|
372
371
|
|
|
372
|
+
import torch
|
|
373
373
|
for idx in trange(0, len(input_list), batch_size, desc="Generation process: "):
|
|
374
|
-
torch.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
374
|
+
with torch.inference_mode():
|
|
375
|
+
torch.cuda.empty_cache()
|
|
376
|
+
batched_prompts = input_list[idx : idx + batch_size]
|
|
377
|
+
inputs = self.tokenizer(
|
|
378
|
+
batched_prompts,
|
|
379
|
+
return_tensors="pt",
|
|
380
|
+
padding=True,
|
|
381
|
+
truncation=True,
|
|
382
|
+
max_length=self.max_input_len,
|
|
383
|
+
).to(self.model.device)
|
|
384
|
+
outputs = self.model.generate(
|
|
385
|
+
**inputs,
|
|
386
|
+
output_scores=True,
|
|
387
|
+
return_dict_in_generate=True,
|
|
388
|
+
**generation_params,
|
|
389
|
+
)
|
|
389
390
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
391
|
+
generated_ids = outputs.sequences
|
|
392
|
+
logits = torch.stack(outputs.scores, dim=1).softmax(-1)
|
|
393
|
+
generated_ids = generated_ids[:, inputs["input_ids"].shape[-1] :]
|
|
394
|
+
gen_score = torch.gather(logits, 2, generated_ids[:, :, None]).squeeze(-1).cpu().tolist()
|
|
395
|
+
scores.extend(gen_score)
|
|
395
396
|
|
|
396
397
|
# get additinoal info
|
|
397
398
|
if return_dict:
|
|
@@ -477,13 +478,14 @@ class HFCausalLMGenerator(BaseGenerator):
|
|
|
477
478
|
else:
|
|
478
479
|
return responses
|
|
479
480
|
|
|
480
|
-
|
|
481
|
+
|
|
481
482
|
def cal_gen_probs(self, prev, next):
|
|
483
|
+
import torch
|
|
482
484
|
input_ids = self.tokenizer.encode(prev, add_special_tokens=False)
|
|
483
485
|
target_ids = self.tokenizer.encode(next, add_special_tokens=False)
|
|
484
486
|
context_ids = input_ids + target_ids
|
|
485
487
|
context_tensor = torch.tensor([context_ids]).to(self.device)
|
|
486
|
-
with torch.
|
|
488
|
+
with torch.inference_mode():
|
|
487
489
|
outputs = self.model(context_tensor)
|
|
488
490
|
logits = outputs.logits
|
|
489
491
|
logits = logits[0, len(input_ids) - 1 : len(context_ids) - 1, :]
|
|
@@ -505,6 +507,7 @@ class FastChatGenerator(HFCausalLMGenerator):
|
|
|
505
507
|
|
|
506
508
|
def get_gpu_memory(max_gpus=None):
|
|
507
509
|
"""Get available memory for each GPU."""
|
|
510
|
+
import torch
|
|
508
511
|
gpu_memory = []
|
|
509
512
|
num_gpus = torch.cuda.device_count() if max_gpus is None else min(max_gpus, torch.cuda.device_count())
|
|
510
513
|
for gpu_id in range(num_gpus):
|
|
@@ -525,6 +528,8 @@ class FastChatGenerator(HFCausalLMGenerator):
|
|
|
525
528
|
else:
|
|
526
529
|
gpu_memory_utilization = self.config["gpu_memory_utilization"]
|
|
527
530
|
max_gpu_memory = None
|
|
531
|
+
import torch
|
|
532
|
+
self.gpu_num = torch.cuda.device_count()
|
|
528
533
|
if self.gpu_num != 1:
|
|
529
534
|
available_gpu_memory = get_gpu_memory(self.gpu_num)
|
|
530
535
|
max_gpu_memory = str(int(min(available_gpu_memory) * gpu_memory_utilization)) + "GiB"
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/__init__.py
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
from flashrag.pipeline.pipeline import *
|
|
2
2
|
from flashrag.pipeline.branching_pipeline import REPLUGPipeline, SuRePipeline
|
|
3
|
-
from flashrag.pipeline.active_pipeline import IterativePipeline, SelfRAGPipeline, FLAREPipeline, SelfAskPipeline, IRCOTPipeline
|
|
3
|
+
from flashrag.pipeline.active_pipeline import IterativePipeline, SelfRAGPipeline, FLAREPipeline, SelfAskPipeline, IRCOTPipeline, RQRAGPipeline
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import re
|
|
2
2
|
from tqdm import tqdm
|
|
3
|
+
from typing import List, Tuple
|
|
3
4
|
import math
|
|
4
5
|
import numpy as np
|
|
5
6
|
from transformers import AutoTokenizer, PreTrainedTokenizer, PreTrainedTokenizerFast
|
|
@@ -1049,10 +1050,7 @@ class RQRAGPipeline(BasicPipeline):
|
|
|
1049
1050
|
"spaces_between_special_tokens": False,
|
|
1050
1051
|
"max_tokens": 4096
|
|
1051
1052
|
}
|
|
1052
|
-
|
|
1053
|
-
from flashrag.dataset import Dataset, Item
|
|
1054
|
-
from typing import List, Tuple
|
|
1055
|
-
|
|
1053
|
+
|
|
1056
1054
|
def __init__(
|
|
1057
1055
|
self,
|
|
1058
1056
|
config: dict,
|
|
@@ -1074,7 +1072,7 @@ class RQRAGPipeline(BasicPipeline):
|
|
|
1074
1072
|
|
|
1075
1073
|
# Due to the low effiency of original method, it only supports vllm now.
|
|
1076
1074
|
|
|
1077
|
-
def preprocess_eval_data(self, items: List
|
|
1075
|
+
def preprocess_eval_data(self, items: List) -> List[str]:
|
|
1078
1076
|
eval_examples = []
|
|
1079
1077
|
|
|
1080
1078
|
for item in items:
|
|
@@ -1214,12 +1212,11 @@ class RQRAGPipeline(BasicPipeline):
|
|
|
1214
1212
|
|
|
1215
1213
|
return pred, best_path
|
|
1216
1214
|
|
|
1217
|
-
def run(self, dataset
|
|
1215
|
+
def run(self, dataset, do_eval = True):
|
|
1218
1216
|
preds = []
|
|
1219
1217
|
meta_results = []
|
|
1220
1218
|
|
|
1221
|
-
|
|
1222
|
-
for i in tqdm(range(0, len(dataset), self.batch_size)):
|
|
1219
|
+
for i in tqdm(range(0, len(dataset), self.batch_size), position=0, desc='RQRAG Process'):
|
|
1223
1220
|
batch_items = dataset[i : i + self.batch_size]
|
|
1224
1221
|
eval_datas = self.preprocess_eval_data(batch_items)
|
|
1225
1222
|
paths_batch = self.generate_tree_of_thoughts_batch(initial_prompts_batch = eval_datas)
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/prompt/base_prompt.py
RENAMED
|
@@ -79,6 +79,8 @@ class PromptTemplate:
|
|
|
79
79
|
return truncated_messages
|
|
80
80
|
|
|
81
81
|
else:
|
|
82
|
+
if self.tokenizer is None:
|
|
83
|
+
self.tokenizer = AutoTokenizer.from_pretrained(self.generator_path, trust_remote_code=True)
|
|
82
84
|
assert isinstance(prompt, str)
|
|
83
85
|
tokenized_prompt = self.tokenizer(prompt, truncation=False, return_tensors="pt").input_ids[0]
|
|
84
86
|
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/retriever.py
RENAMED
|
@@ -339,7 +339,7 @@ class DenseRetriever(BaseRetriever):
|
|
|
339
339
|
results = []
|
|
340
340
|
scores = []
|
|
341
341
|
|
|
342
|
-
for start_idx in
|
|
342
|
+
for start_idx in range(0, len(query_list), batch_size):
|
|
343
343
|
query_batch = query_list[start_idx : start_idx + batch_size]
|
|
344
344
|
batch_emb = self.encoder.encode(query_batch)
|
|
345
345
|
batch_scores, batch_idxs = self.index.search(batch_emb, k=num)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.4dev20241214"
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214/flashrag_dev.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flashrag-dev
|
|
3
|
-
Version: 0.1.4.
|
|
3
|
+
Version: 0.1.4.dev20241214
|
|
4
4
|
Summary: A library for efficient Retrieval-Augmented Generation research
|
|
5
5
|
Home-page: https://github.com/RUC-NLPIR/FlashRAG
|
|
6
6
|
Author: Jiajie Jin, Yutao Zhu, Chenghao Zhang, Xinyu Yang, Zhicheng Dou
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.4dev20241208"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/config/__init__.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/config/basic_config.yaml
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/dataset/__init__.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/dataset/dataset.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/__init__.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/_bleu.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/evaluator.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/metrics.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/evaluator/utils.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/generator/utils.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/judger/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/pipeline.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/pipeline/replug_utils.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/prompt/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/prompt/trace_examplars.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/__init__.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/kg_refiner.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/refiner/refiner.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/__init__.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/__main__.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/encoder.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/reranker.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/retriever/utils.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/utils/__init__.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/utils/constants.py
RENAMED
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag/utils/pred_parse.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag_dev.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag-dev-0.1.4.dev20241208 → flashrag-dev-0.1.4.dev20241214}/flashrag_dev.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|