diff --git a/prompting/__init__.py b/prompting/__init__.py index 05b881734..8b97c2188 100644 --- a/prompting/__init__.py +++ b/prompting/__init__.py @@ -16,7 +16,7 @@ # DEALINGS IN THE SOFTWARE. # Define the version of the template module. -__version__ = "2.6.0" +__version__ = "2.6.2" version_split = __version__.split(".") __spec_version__ = ( (10000 * int(version_split[0])) diff --git a/prompting/mock.py b/prompting/mock.py index 34b172a82..5fbd2c8bd 100644 --- a/prompting/mock.py +++ b/prompting/mock.py @@ -83,6 +83,10 @@ def postprocess(self, output, **kwargs): def preprocess(self, **kwargs): pass + def generate(self, *args, **kwargs) -> list[SimpleNamespace]: + mock_output = SimpleNamespace(outputs=[SimpleNamespace(text=self.model.phrase)]) + return [mock_output] + class MockSubtensor(bt.MockSubtensor): def __init__(self, netuid, n=16, wallet=None): diff --git a/prompting/organic/organic_scoring_prompting.py b/prompting/organic/organic_scoring_prompting.py index 68fb93791..034cd044b 100644 --- a/prompting/organic/organic_scoring_prompting.py +++ b/prompting/organic/organic_scoring_prompting.py @@ -305,8 +305,8 @@ async def _set_weights(self, reward: dict[str, Any]): uids_to_reward = dict(zip(uids, reward_result.rewards)) bt.logging.info(f"[Organic] Rewards for miner's UIDs: {uids_to_reward}") - bt.logging.info(f"[Organic] Weight setting enabled: {self._val.config.neuron.organic_set_weights_enabled}") - if self._val.config.neuron.organic_set_weights_enabled: + bt.logging.info(f"[Organic] Weight setting disabled: {self._val.config.neuron.organic_disable_set_weights}") + if not self._val.config.neuron.organic_disable_set_weights: self._val.update_scores(reward_result.rewards, uids) # Sync is not needed as it's done in the benchmarks loop. # self._val.sync() @@ -326,6 +326,7 @@ async def _log_results( logs["step"] = self._val.step # Length of messages is incremented by 2 every step: query and response. logs["turn"] = len(sample["messages"]) // 2 + logs["uids"] = rewards["uids"] completions_len: list[int] = [len(response.synapse.completion) for response in responses.values()] logs["organic_response_mean_chars"] = np.mean(completions_len) logs["organic_response_std_chars"] = np.std(completions_len) diff --git a/prompting/tools/datasets/wiki.py b/prompting/tools/datasets/wiki.py index 9813a41a7..8d1d90991 100644 --- a/prompting/tools/datasets/wiki.py +++ b/prompting/tools/datasets/wiki.py @@ -113,8 +113,10 @@ def process_page( sections = {k: v for k, v in sections.items() if k not in exclude_sections} if selector == "all": - return ("Full Page", "\n\n".join(sections.values())) , sections.keys() - + content = "\n\n".join(sections.values()) + if not valid_section or valid_section(content): + return ("Full Page", content), sections.keys() + return None, sections.keys() valid_sections = [(key, value) for key, value in sections.items() if not valid_section or valid_section(sections[key])] if valid_sections: @@ -246,7 +248,7 @@ def random(self, pages=10, seed=None, selector: Selector = None, **kwargs) -> Di if seed is None else _get_random_titles(pages=pages, seed=seed) ) - title = selector(titles) + title = random.choice(titles) return self.get(title, selector=selector) @@ -316,7 +318,9 @@ def _random_date(self) -> str: date_sentence = self.extract_dates_and_sentences(context['content']) context['content'] = date_sentence[1] context['extra']['date'] = date_sentence[0] - if context['content'] is None: + if not context['content']: + continue + elif not context['extra']['date']: continue else: return context @@ -324,6 +328,10 @@ def _random_date(self) -> str: except Empty: bt.logging.debug("Cache is empty. Skipping date until cache is filled.") return None + + except Exception as e: + bt.logging.error(f"Error fetching date: {e}") + continue def get( self, diff --git a/prompting/utils/config.py b/prompting/utils/config.py index 46aea9eff..4e5991f97 100644 --- a/prompting/utils/config.py +++ b/prompting/utils/config.py @@ -302,7 +302,7 @@ def parse_probabilities(prob_list): return [float(p) for p in prob_list] except ValueError: raise argparse.ArgumentTypeError("All probabilities must be floats.") - + parser.add_argument( "--neuron.task_p", type=parse_probabilities, # Use the custom parsing function @@ -430,15 +430,14 @@ def parse_probabilities(prob_list): parser.add_argument( "--neuron.organic_disabled", action="store_true", - help="Set this flag to disable organic scoring.", + help="Disables organic scoring.", default=False, ) - # TODO: Set organic weight setting enabled by default after Aug 1, 2024. parser.add_argument( - "--neuron.organic_set_weights_enabled", + "--neuron.organic_disable_set_weights", action="store_true", - help="Set this flag to enable organic scoring weight setting.", + help="Disables organic scoring weight setting.", default=False, ) @@ -467,11 +466,10 @@ def parse_probabilities(prob_list): parser.add_argument( "--neuron.organic_reference_max_tokens", type=int, - help="Organic query timeout for each call in seconds.", + help="Organic reference max tokens.", default=1024, ) - # TODO: Increase sampling rate after after Aug 1, 2024. parser.add_argument( "--neuron.organic_trigger_frequency", type=float, diff --git a/requirements.txt b/requirements.txt index 1c93400f9..9854a7db7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ angle_emb==0.4.4 -bittensor==7.1.1 +git+https://github.com/opentensor/bittensor.git@release/7.1.2#egg=bittensor bs4==0.0.2 click==8.1.3 datasets==2.14.6