Skip to content

Commit a54e67a

Browse files
authored
Merge pull request #206 from ComplexData-MILA/caching-none
Caching none
2 parents 10f500c + 25df292 commit a54e67a

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

aif_gen/generate/engine.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,11 @@ async def _generate_sample(
271271
meta_prompt_nonce = f'{prompt_idx}'
272272

273273
async with async_semaphore:
274+
output = None
274275
if cache is not None:
275276
output = await cache.get(meta_prompt, nonce=meta_prompt_nonce)
276-
else:
277+
278+
if output is None: # Cache miss or no cache - make API call
277279
response = await client.chat.completions.create(
278280
model=model_name,
279281
messages=[{'role': 'user', 'content': meta_prompt}],
@@ -306,9 +308,11 @@ async def _generate_sample(
306308
task_prompt = task_prompt1 + task_prompt2
307309

308310
async with async_semaphore:
311+
output = None
309312
if cache is not None:
310313
output = await cache.get(task_prompt1 + task_prompt2)
311-
else:
314+
315+
if output is None: # Cache miss or no cache - make API calls
312316
futures = []
313317
for response_prompt in [task_prompt1, task_prompt2]:
314318
coro = client.chat.completions.create(
@@ -346,9 +350,11 @@ async def _generate_sample(
346350
else:
347351
task_prompt = response_mapper.generate_prompt(task, prompt)
348352
async with async_semaphore:
353+
output = None
349354
if cache is not None:
350355
output = await cache.get(task_prompt)
351-
else:
356+
357+
if output is None: # Cache miss or no cache - make API call
352358
response = await client.chat.completions.create(
353359
model=model_name,
354360
messages=[{'role': 'user', 'content': task_prompt}],

aif_gen/generate/mappers/response_mapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class ResponseMapper(ResponseMapperBase):
1515
"""
1616

1717
NUM_PREFERENCE_AXES_SAMPLES: int = 3
18-
PREFERENCE_INCLUSION_PROB_POS: float = 0.5
19-
PREFERENCE_INCLUSION_PROB_NEG: float = 0.5
18+
PREFERENCE_INCLUSION_PROB_POS: float = 0.8
19+
PREFERENCE_INCLUSION_PROB_NEG: float = 0.8
2020

2121
def __init__(self, suffix_context: Optional[str] = None) -> None:
2222
self._suffix_context = suffix_context

0 commit comments

Comments
 (0)