MCPcopy Create free account
hub / github.com/AkaliKong/MiniOneRec / EvalD3Dataset

Class EvalD3Dataset

data.py:262–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260
261
262class EvalD3Dataset(CSVBaseDataset):
263
264 def __init__(self, train_file, tokenizer, max_len=2048, sample=-1, test = False, seed=0, category="", K=4, dedup=False):
265 super().__init__(train_file, sample, seed, max_len, category, dedup, tokenizer, test)
266
267 self.instructs = [
268 f"Given a list of {category} the user recetenly enjoy, please write a new {category} that the user may bought",
269 f"Considering the {category} that has recently captured the user's interest, kindly create a compilation of other {category} that the user might have played prior to this.",
270 f"Based on the user's current gaming preference, please draft a list of potential {category} they may have experienced beforehand.",
271 f"Reflecting on the {category} the user has taken pleasure in recently, we request that you formulate a list of {category} that may have preceded the user's current enjoyment.",
272 f"In light of the recent gaming enjoyment expressed by the user, please assemble a list of {category} that could potentially include past titles the user has engaged with.",
273 f"Taking into account the {category} that has lately provided enjoyment to the user, please put together an inventory of {category} the user might have explored previously.",
274 f"Given the user's newfound enjoyment of a particular {category}, would you kindly generate a roster of other {category} that might resonate with their past gaming experiences?",
275 f"In response to the user's recent fondness for a specific {category}, we seek your assistance in listing possible {category} the user may have delighted in earlier.",
276 f"With respect to the {category} currently enjoyed by the user, please compile a suggestive list of {category} they may have played in the past.",
277 f"Bearing in mind the {category} that the user has recently been enthralled by, please construct a catalog of other {category} that the user potentially partook in beforehand.",
278 f"In relation to the user's recent entertainment with a given {category}, it would be appreciated if you could curate a list of {category} that might form part of the user's previous gaming history."
279 ]
280 self.get_inputs()
281
282 def generate_example_prompt(self, data_point):
283 return f"""### Example {data_point["idx"]}:
284{data_point["input"]}
285
286### Response:\n{data_point["output"]}
287"""
288 def get_history(self, row):
289 row['history_item_title'] = eval(row['history_item_title'])
290 L = len(row['history_item_title'])
291 history = ""
292 for i in range(L):
293 if i == 0:
294 history += "\"" + row['history_item_title'][i] + "\""
295 else:
296 history += ",\t\"" + row['history_item_title'][i] + "\""
297 target_item = str(row['item_title'])
298 target_item = "\"" + target_item + "\""
299 target_item_id = row["item_id"]
300 last_history_item_id = eval(row["history_item_id"])[-1]
301 return {"input": f"The user has palyed the following {self.category}s before: {history}",
302 "output": target_item + '\n',
303 "dedup": target_item_id == last_history_item_id}
304
305 def pre(self, idx):
306 instruction = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
307
308### Instruction:
309{self.instructs[random.randint(0, len(self.instructs)-1)]}\n
310"""
311 tokens = self.tokenizer.encode(instruction, bos=True, eos=False)
312
313 history = self.get_history(self.data.iloc[idx])
314 target_item = history['output']
315 history['output'] = ''
316 negative_prompt_ids = copy.deepcopy(tokens)
317
318
319

Callers 1

Calls

no outgoing calls

Tested by 1