Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prompting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
4 changes: 4 additions & 0 deletions prompting/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions prompting/organic/organic_scoring_prompting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions prompting/tools/datasets/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -316,14 +318,20 @@ 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

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,
Expand Down
12 changes: 5 additions & 7 deletions prompting/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down