Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.1.1 #126

Merged
merged 22 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4b417bc
Allow penalty definition weights to not sum to 1
steffencruz Feb 21, 2024
1e2761c
Reduce penalty weight to 0.5
steffencruz Feb 21, 2024
8d8c147
Reduce penalty weight to 0.5
steffencruz Feb 21, 2024
e28591c
Allow penalty definition weights to not add to 1
steffencruz Feb 21, 2024
5908d20
Remove default arg
steffencruz Feb 22, 2024
ca068e1
Update miner.py
steffencruz Feb 22, 2024
2c2b68b
Update miner.py
steffencruz Feb 22, 2024
f062ef7
Update miner.py
steffencruz Feb 22, 2024
3193f60
Update echo.py
steffencruz Feb 22, 2024
05508a2
Update mock.py
steffencruz Feb 22, 2024
725c78f
Update phrase.py
steffencruz Feb 22, 2024
0c48a86
Fix self->miner typo
steffencruz Feb 22, 2024
0089158
Fix self->miner typo
steffencruz Feb 22, 2024
5ba7894
Change auto_suggest and redirect to false so that wiki api does not t…
steffencruz Feb 28, 2024
8013835
Reformat wiki date page title
steffencruz Feb 28, 2024
fc52946
Adjust assert statements
steffencruz Feb 28, 2024
cdb24c1
Use MaxRetryError, reduce logging level and fix typo in log
steffencruz Feb 28, 2024
9dcbe56
Merge pull request #120 from opentensor/logging/status
steffencruz Feb 28, 2024
9bab31d
Merge pull request #115 from opentensor/114-reduce-penalty-weight
steffencruz Feb 28, 2024
a39254a
Merge pull request #124 from opentensor/hotfix/date-qa-redirect
steffencruz Feb 28, 2024
215b457
updates package versioning
p-ferreira Feb 28, 2024
11ec3ee
Merge pull request #128 from opentensor/hotfix/release-versioning
steffencruz Feb 28, 2024
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
11 changes: 7 additions & 4 deletions neurons/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ def log_event(self, timing: float, prompt: str, completion: str, system_prompt:
bt.logging.info('Logging event to wandb...', step_log)
wandb.log(step_log)

def log_status(self):
m = self.metagraph
bt.logging.info(f"Miner running:: network: {self.subtensor.network} | block: {self.block} | step: {self.step} | uid: {self.uid} | last updated: {self.block-m.last_update[self.uid]} | trust: {m.trust[self.uid]:.3f} | emission {m.emission[self.uid]:.3f}")

# This is the main function, which runs the miner.
if __name__ == "__main__":
with Miner() as m:
with Miner() as miner:
while True:
bt.logging.info(f"Miner running:: network: {m.subtensor.network} | block: {m.block} | step: {m.step} | uid: {m.uid} | last updated: {m.block-m.metagraph.last_update[m.uid]} | trust: {m.metagraph.trust[m.uid]:.3f} | emission {m.metagraph.emission[m.uid]:.3f}")
miner.log_status()
time.sleep(5)

if m.should_exit:
if miner.should_exit:
bt.logging.warning("Ending miner...")
break
break
2 changes: 1 addition & 1 deletion neurons/miners/openai/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async def forward(
if __name__ == "__main__":
with OpenAIMiner() as miner:
while True:
bt.logging.info("Miner running...", time.time())
miner.log_status()
time.sleep(5)

if miner.should_exit:
Expand Down
2 changes: 1 addition & 1 deletion neurons/miners/test/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ async def priority(self, synapse: PromptingSynapse) -> float:
if __name__ == "__main__":
with EchoMiner() as miner:
while True:
bt.logging.info("Miner running...", time.time())
miner.log_status()
time.sleep(5)
2 changes: 1 addition & 1 deletion neurons/miners/test/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ async def priority(self, synapse: PromptingSynapse) -> float:
if __name__ == "__main__":
with MockMiner() as miner:
while True:
bt.logging.info("Miner running...", time.time())
miner.log_status()
time.sleep(5)
2 changes: 1 addition & 1 deletion neurons/miners/test/phrase.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ async def priority(self, synapse: PromptingSynapse) -> float:
if __name__ == "__main__":
with PhraseMiner() as miner:
while True:
bt.logging.info("Miner running...", time.time())
miner.log_status()
time.sleep(5)
2 changes: 1 addition & 1 deletion neurons/miners/wiki_agent/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def forward(
if __name__ == "__main__":
with WikipediaAgentMiner() as miner:
while True:
bt.logging.info("Miner running...", time.time())
miner.log_status()
time.sleep(5)

if miner.should_exit:
Expand Down
2 changes: 1 addition & 1 deletion neurons/miners/zephyr/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def forward(self, synapse: PromptingSynapse) -> PromptingSynapse:
if __name__ == "__main__":
with ZephyrMiner() as miner:
while True:
bt.logging.info("Miner running...", time.time())
miner.log_status()
time.sleep(5)

if miner.should_exit:
Expand Down
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__ = "1.1.0"
__version__ = "1.1.1"
version_split = __version__.split(".")
__spec_version__ = (
(10000 * int(version_split[0]))
Expand Down
10 changes: 5 additions & 5 deletions prompting/rewards/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def validate_tasks(self):
f"Task {task} not supported. Please choose from {TASKS.keys()}"
)
# Check that the reward_definition and penalty_definition are lists of dictionaries whose weights sum to one
self._check_weights(task, "reward_definition")
self._check_weights(task, "penalty_definition")
self._check_weights(task, "reward_definition", expected_weight=1)
self._check_weights(task, "penalty_definition", expected_weight=None)

def _check_weights(self, task, definition):
def _check_weights(self, task, definition, expected_weight):

total_weight = 0

Expand All @@ -66,8 +66,8 @@ def _check_weights(self, task, definition):

total_weight += weight

if model_infos and total_weight != 1:
raise ValueError(f"{definition} model {model_infos} weights do not sum to 1 (sum={total_weight})")
if model_infos and expected_weight is not None and total_weight != expected_weight:
raise ValueError(f"{definition} model {model_infos} weights do not sum to {expected_weight} (sum={total_weight})")

def load_pipeline(self):
"""Dynamically loads the reward models required by the selected tasks so that we only use the necessary resources."""
Expand Down
2 changes: 1 addition & 1 deletion prompting/tasks/qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class QuestionAnsweringTask(Task):
dict(name="relevance", weight=0.5),
]
penalty_definition = [
dict(name="rouge", ngram="rouge-1", metric="f", weight=1.0),
dict(name="rouge", ngram="rouge-1", metric="f", weight=0.5),
]

cleaning_pipeline = [
Expand Down
2 changes: 1 addition & 1 deletion prompting/tasks/summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SummarizationTask(Task):
dict(name="relevance", weight=0.5),
]
penalty_definition = [
dict(name="rouge", ngram="rouge-1", metric="f", weight=1.0)
dict(name="rouge", ngram="rouge-1", metric="f", weight=0.5)
]

# This is where you define cleaning procedures for the generation.
Expand Down
9 changes: 5 additions & 4 deletions prompting/tools/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from ..selector import Selector
from .context import Context
from prompting.utils.exceptions import MaxRetryError


class Dataset(ABC):
Expand Down Expand Up @@ -62,12 +63,12 @@ def next(self, method: str = 'random', selector: Selector = Selector(), **kwargs
if info:
break

bt.logging.warning(f"Could not find an sample which meets {self.__class__.__name__} requirements after {tries} tries. Retrying... ({self.max_tries - tries} tries remaining.)")
bt.logging.debug(f"Could not find any samples which meet {self.__class__.__name__} requirements after {tries} tries. Retrying... ({self.max_tries - tries} tries remaining.)")

tries += 1
if tries == self.max_tries:
raise Exception(
f"Could not find an sample which meets {self.__class__.__name__} requirements after {tries} tries."
if tries >= self.max_tries:
raise MaxRetryError(
f"Could not find any samples which meet {self.__class__.__name__} requirements after {tries} tries."
)

info['stats'] = {
Expand Down
10 changes: 5 additions & 5 deletions prompting/tools/datasets/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ def _random_date(self, year: int = None, month: int = None) -> int:

random_date = datetime.date(year, month, day)
# Step 2: Format the date for Wikipedia URL
return random_date.strftime("%B_%d") # E.g., "January_01"
return random_date.strftime("%B %-d") # E.g., "January 1"

def get(self, name, pageid=None, auto_suggest=True, redirect=True, selector: Selector = None) -> Dict:
def get(self, name, pageid=None, auto_suggest=False, redirect=False, selector: Selector = None) -> Dict:

# Check that name is correctly formatted e.g., "January_01"
date = name.split('_')
assert len(date)==2, f"Date should be in the format 'Month_DD' (e.g., 'January_01'), but got {name!r}"
# Check that name is correctly formatted e.g., "January 1"
date = name.split(' ')
assert len(date)==2, f"Date should be in the format 'Month D[D]' (e.g., 'January 1' or 'March 28'), but got {name!r}"
assert date[0] in self.MONTHS, f"Month should be one of {self.MONTHS}, but got {date[0]!r}"
assert date[1].isdigit(), f"Day should be a number, but got {date[1]!r}"

Expand Down
6 changes: 3 additions & 3 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def test_task_state_dict(task: Task, full: bool):


@pytest.mark.parametrize('task', TASKS)
@pytest.mark.parametrize('definition', ('reward_definition', 'penalty_definition'))
def test_task_contains_required_definition(task: Task, definition: str):
@pytest.mark.parametrize('definition, expected_weight', [('reward_definition',1), ('penalty_definition',None)])
def test_task_contains_required_definition(task: Task, definition: str, expected_weight: float):

task = task(llm_pipeline=LLM_PIPELINE, context=CONTEXTS[task])
model_infos = getattr(task, definition)
Expand Down Expand Up @@ -110,4 +110,4 @@ def test_task_contains_required_definition(task: Task, definition: str):

total_weight += weight

assert not model_infos or total_weight == 1
assert not model_infos or expected_weight is None or total_weight == expected_weight
Loading