diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b1d63b2a84f43690fe8d7878fbb8b59c6a9bd772 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/_version.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/_version.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..81adaf346730d63cfd083a302d5f074092ec9002 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/_version.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/session.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/session.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9aabdd3f9aefc94675e44d8251d1ea5b3cc073d3 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/__pycache__/session.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__init__.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..195de366165ddcce2326ec1c0508b3d3e273163d Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__pycache__/table.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__pycache__/table.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e0e24befe565c973d09573820ef1c7832972a120 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/__pycache__/table.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/table.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/table.py new file mode 100644 index 0000000000000000000000000000000000000000..01a20097956a047af9d2d09d22bf0ec17f9dc5ba --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/dynamodb/table.py @@ -0,0 +1,134 @@ +import asyncio +import logging + +from boto3.dynamodb.table import TableResource + +logger = logging.getLogger(__name__) + + +def register_table_methods(base_classes, **kwargs): + base_classes.insert(0, CustomTableResource) + + +class CustomTableResource(TableResource): + def batch_writer(self, overwrite_by_pkeys=None, flush_amount=25, on_exit_loop_sleep=0): + return BatchWriter( + self.name, self.meta.client, + flush_amount=flush_amount, + overwrite_by_pkeys=overwrite_by_pkeys, + on_exit_loop_sleep=on_exit_loop_sleep + ) + + +class BatchWriter(object): + """ + Modified so that it does async + Automatically handle batch writes to DynamoDB for a single table. + """ + + def __init__( + self, table_name, client, flush_amount=25, overwrite_by_pkeys=None, on_exit_loop_sleep=0 + ): + """ + + :type table_name: str + :param table_name: The name of the table. The class handles + batch writes to a single table. + + :type client: ``botocore.client.Client`` + :param client: A botocore client. Note this client + **must** have the dynamodb customizations applied + to it for transforming AttributeValues into the + wire protocol. What this means in practice is that + you need to use a client that comes from a DynamoDB + resource if you're going to instantiate this class + directly, i.e + ``boto3.resource('dynamodb').Table('foo').meta.client``. + + :type flush_amount: int + :param flush_amount: The number of items to keep in + a local buffer before sending a batch_write_item + request to DynamoDB. + + :type overwrite_by_pkeys: list(string) + :param overwrite_by_pkeys: De-duplicate request items in buffer + if match new request item on specified primary keys. i.e + ``["partition_key1", "sort_key2", "sort_key3"]`` + + :type on_exit_loop_sleep: int + :param on_exit_loop_sleep: When aexit is called by exiting the + context manager, if the value is > 0 then every time flush + is called a sleep will also be called. + + """ + self._table_name = table_name + self._client = client + self._items_buffer = [] + self._flush_amount = flush_amount + self._overwrite_by_pkeys = overwrite_by_pkeys + self._on_exit_loop_sleep = on_exit_loop_sleep + + async def put_item(self, Item): + await self._add_request_and_process({'PutRequest': {'Item': Item}}) + + async def delete_item(self, Key): + await self._add_request_and_process({'DeleteRequest': {'Key': Key}}) + + async def _add_request_and_process(self, request): + if self._overwrite_by_pkeys: + self._remove_dup_pkeys_request_if_any(request) + self._items_buffer.append(request) + await self._flush_if_needed() + + def _remove_dup_pkeys_request_if_any(self, request): + pkey_values_new = self._extract_pkey_values(request) + for item in self._items_buffer: + if self._extract_pkey_values(item) == pkey_values_new: + self._items_buffer.remove(item) + logger.debug("With overwrite_by_pkeys enabled, skipping request:%s", item) + + def _extract_pkey_values(self, request): + if request.get('PutRequest'): + return [ + request['PutRequest']['Item'][key] + for key in self._overwrite_by_pkeys + ] + elif request.get('DeleteRequest'): + return [ + request['DeleteRequest']['Key'][key] + for key in self._overwrite_by_pkeys + ] + return None + + async def _flush_if_needed(self): + if len(self._items_buffer) >= self._flush_amount: + await self._flush() + + async def _flush(self): + items_to_send = self._items_buffer[:self._flush_amount] + self._items_buffer = self._items_buffer[self._flush_amount:] + response = await self._client.batch_write_item( + RequestItems={self._table_name: items_to_send}) + unprocessed_items = response['UnprocessedItems'] + + if not unprocessed_items: + unprocessed_items = {} + item_list = unprocessed_items.get(self._table_name, []) + # Any unprocessed_items are immediately added to the + # next batch we send. + self._items_buffer.extend(item_list) + logger.debug( + "Batch write sent %s, unprocessed: %s, buffer %s", + len(items_to_send), len(item_list), len(self._items_buffer) + ) + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, tb): + # When we exit, we need to keep flushing whatever's left + # until there's nothing left in our items buffer. + while self._items_buffer: + await self._flush() + if self._items_buffer and self._on_exit_loop_sleep: + await asyncio.sleep(self._on_exit_loop_sleep) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__init__.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8c3ed7d23e864cedcfe2717c87d7c8b04c90033c Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__pycache__/async_chalice.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__pycache__/async_chalice.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9caf25f13461872712db37852d7ace614a05b642 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/__pycache__/async_chalice.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/async_chalice.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/async_chalice.py new file mode 100644 index 0000000000000000000000000000000000000000..7320c48fe36b1e714f00420ae4d395b0623ffb1d --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/experimental/async_chalice.py @@ -0,0 +1,41 @@ +import asyncio +from typing import Optional + +from chalice import Chalice +from chalice.app import RestAPIEventHandler + +from aioboto3 import Session + + +class AsyncRestAPIEventHandler(RestAPIEventHandler): + def _get_view_function_response(self, view_function, function_args): + # Wrap the view_function so that we can return either the normal response + # or if its a co-routine, run it in an event loop first. + # Saves duplicating the whole function. + def _fake_view_function(**kwargs): + response = view_function(**kwargs) + if asyncio.iscoroutine(response): + # Always run in a new loop as chalice would close an existing one anyway + new_loop = asyncio.new_event_loop() + response = new_loop.run_until_complete(response) + new_loop.close() + + return response + return super(AsyncRestAPIEventHandler, self)._get_view_function_response(_fake_view_function, function_args) + + +class AsyncChalice(Chalice): + def __init__(self, *args, aioboto3_session: Optional[Session] = None, **kwargs): + super(AsyncChalice, self).__init__(*args, **kwargs) + + self.aioboto3 = aioboto3_session or Session() + + def __call__(self, event, context): + self.lambda_context = context + handler = AsyncRestAPIEventHandler( + self.routes, self.api, self.log, self.debug, + middleware_handlers=self._get_middleware_handlers('http') + ) + self.current_request = handler.create_request_object(event, context) + return handler(event, context) + diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__init__.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ffe88284bf8952530f7207611c358fe95061f806 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/action.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/action.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dece5c6f8fb4e8060cba44fbc099b818c94a325c Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/action.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/base.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/base.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b690c293c1fe34b9e783c4069f27c29eb3c82f9a Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/base.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/collection.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/collection.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e93d7b1e5e07172a91ca084eca8ea5b315933e5f Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/collection.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/factory.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/factory.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3dc831f6b7fac511519150269cc1a9dee7a4e056 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/factory.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/response.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/response.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..869cc66bd01289343b997f6719975faa6021425a Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/__pycache__/response.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/action.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/action.py new file mode 100644 index 0000000000000000000000000000000000000000..5612d73775fd359291f4b37c7ad46b35683b2bd7 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/action.py @@ -0,0 +1,118 @@ +import logging + +from boto3.resources.action import ServiceAction, WaiterAction +from boto3.resources.params import create_request_parameters +from boto3.resources.action import xform_name + +from aioboto3.resources.response import AIOResourceHandler, AIORawHandler + +logger = logging.getLogger(__name__) + + +class AIOServiceAction(ServiceAction): + def __init__(self, action_model, factory=None, service_context=None): + self._action_model = action_model + + # In the simplest case we just return the response, but if a + # resource is defined, then we must create these before returning. + resource_response_model = action_model.resource + if resource_response_model: + self._response_handler = AIOResourceHandler( + search_path=resource_response_model.path, + factory=factory, + resource_model=resource_response_model, + service_context=service_context, + operation_name=action_model.request.operation + ) + else: + self._response_handler = AIORawHandler(action_model.path) + + async def __call__(self, parent, *args, **kwargs): + operation_name = xform_name(self._action_model.request.operation) + + # First, build predefined params and then update with the + # user-supplied kwargs, which allows overriding the pre-built + # params if needed. + params = create_request_parameters(parent, self._action_model.request) + params.update(kwargs) + + logger.debug('Calling %s:%s with %r', parent.meta.service_name, + operation_name, params) + + response = await getattr(parent.meta.client, operation_name)(*args, **params) + + logger.debug('Response: %r', response) + + return await self._response_handler(parent, params, response) + + +class AioBatchAction(ServiceAction): + async def __call__(self, parent, *args, **kwargs): + service_name = None + client = None + responses = [] + operation_name = xform_name(self._action_model.request.operation) + + # Unlike the simple action above, a batch action must operate + # on batches (or pages) of items. So we get each page, construct + # the necessary parameters and call the batch operation. + async for page in parent.pages(): + params = {} + for index, resource in enumerate(page): + # There is no public interface to get a service name + # or low-level client from a collection, so we get + # these from the first resource in the collection. + if service_name is None: + service_name = resource.meta.service_name + if client is None: + client = resource.meta.client + + create_request_parameters( + resource, self._action_model.request, + params=params, index=index) + + if not params: + # There are no items, no need to make a call. + break + + params.update(kwargs) + + logger.debug('Calling %s:%s with %r', + service_name, operation_name, params) + + response = await (getattr(client, operation_name)(*args, **params)) + + logger.debug('Response: %r', response) + + responses.append( + self._response_handler(parent, params, response)) + + return responses + + +class AIOWaiterAction(WaiterAction): + async def __call__(self, parent, *args, **kwargs): + """ + Perform the wait operation after building operation + parameters. + + :type parent: :py:class:`~boto3.resources.base.ServiceResource` + :param parent: The resource instance to which this action is attached. + """ + client_waiter_name = xform_name(self._waiter_model.waiter_name) + + # First, build predefined params and then update with the + # user-supplied kwargs, which allows overriding the pre-built + # params if needed. + params = create_request_parameters(parent, self._waiter_model) + params.update(kwargs) + + logger.debug('Calling %s:%s with %r', + parent.meta.service_name, + self._waiter_resource_name, params) + + client = parent.meta.client + waiter = client.get_waiter(client_waiter_name) + response = await waiter.wait(**params) + + logger.debug('Response: %r', response) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/base.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/base.py new file mode 100644 index 0000000000000000000000000000000000000000..879159c7ecfa20cd2c5df431af5a9c4a1ec6e23d --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/base.py @@ -0,0 +1,18 @@ +import logging +import warnings + +from boto3.resources.base import ServiceResource + +logger = logging.getLogger(__name__) + + +class AIOBoto3ServiceResource(ServiceResource): + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + await self.meta.client.__aexit__(exc_type, exc_val, exc_tb) + + def close(self): + warnings.warn("This should not be called anymore", DeprecationWarning) + return self.meta.client.close() diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/collection.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/collection.py new file mode 100644 index 0000000000000000000000000000000000000000..9aef327ed573303f1564f7aef363597f12fade19 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/collection.py @@ -0,0 +1,189 @@ +import logging +from typing import AsyncIterator, Any, cast + +from boto3.docs import docstring +from boto3.resources.collection import CollectionFactory, ResourceCollection, CollectionManager, merge_dicts +from boto3.resources.params import create_request_parameters + +from aioboto3.resources.action import AioBatchAction, AIOResourceHandler + +logger = logging.getLogger(__name__) + + +class AIOResourceCollection(ResourceCollection): + """ + Converted the ResourceCollection.pages() function to an async generator so that we can do + async for on a paginator inside that function + + Converted the __iter__ + """ + async def __anext__(self): + limit = self._params.get('limit', None) + + count = 0 + async for page in cast(AsyncIterator[Any], self.pages()): + for item in page: + yield item + + count += 1 + if limit is not None and count >= limit: + return + + def __aiter__(self): + return self.__anext__() + + def __iter__(self): + raise NotImplementedError('Use async-for instead') + + async def pages(self): + client = self._parent.meta.client + cleaned_params = self._params.copy() + limit = cleaned_params.pop('limit', None) + page_size = cleaned_params.pop('page_size', None) + params = create_request_parameters(self._parent, self._model.request) + merge_dicts(params, cleaned_params, append_lists=True) + + # Is this a paginated operation? If so, we need to get an + # iterator for the various pages. If not, then we simply + # call the operation and return the result as a single + # page in a list. For non-paginated results, we just ignore + # the page size parameter. + if client.can_paginate(self._py_operation_name): + logger.debug( + 'Calling paginated %s:%s with %r', + self._parent.meta.service_name, + self._py_operation_name, + params + ) + paginator = client.get_paginator(self._py_operation_name) + pages = paginator.paginate( + PaginationConfig={'MaxItems': limit, 'PageSize': page_size}, + **params + ) + else: + async def _aiopaginatordummy(): + yield await getattr(client, self._py_operation_name)(**params) + + logger.debug( + 'Calling %s:%s with %r', + self._parent.meta.service_name, + self._py_operation_name, + params + ) + pages = _aiopaginatordummy() + + # Now that we have a page iterator or single page of results + # we start processing and yielding individual items. + count = 0 + async for page in pages: + page_items = [] + for item in await self._handler(self._parent, params, page): + page_items.append(item) + + # If the limit is set and has been reached, then + # we stop processing items here. + count += 1 + if limit is not None and count >= limit: + break + + yield page_items + + # Stop reading pages if we've reached out limit + if limit is not None and count >= limit: + break + + +class AIOCollectionManager(CollectionManager): + _collection_cls = AIOResourceCollection + + def __init__(self, collection_model, parent, factory, service_context): + self._model = collection_model + operation_name = self._model.request.operation + self._parent = parent + + search_path = collection_model.resource.path + self._handler = AIOResourceHandler( + search_path=search_path, + factory=factory, + resource_model=collection_model.resource, + service_context=service_context, + operation_name=operation_name + ) + + +class AIOCollectionFactory(CollectionFactory): + def load_from_definition( + self, resource_name, collection_model, service_context, event_emitter + ): + attrs = {} + collection_name = collection_model.name + + # Create the batch actions for a collection + self._load_batch_actions( + attrs, + resource_name, + collection_model, + service_context.service_model, + event_emitter + ) + # Add the documentation to the collection class's methods + self._load_documented_collection_methods( + attrs=attrs, + resource_name=resource_name, + collection_model=collection_model, + service_model=service_context.service_model, + event_emitter=event_emitter, + base_class=AIOResourceCollection + ) + + if service_context.service_name == resource_name: + cls_name = ( + f'{service_context.service_name}.{collection_name}Collection' + ) + else: + cls_name = f'{service_context.service_name}.{resource_name}.{collection_name}Collection' + + collection_cls = type(str(cls_name), (AIOResourceCollection,), attrs) + + # Add the documentation to the collection manager's methods + self._load_documented_collection_methods( + attrs=attrs, + resource_name=resource_name, + collection_model=collection_model, + service_model=service_context.service_model, + event_emitter=event_emitter, + base_class=AIOCollectionManager + ) + attrs['_collection_cls'] = collection_cls + cls_name += 'Manager' + + return type(str(cls_name), (AIOCollectionManager,), attrs) + + def _create_batch_action( + factory_self, + resource_name, + snake_cased, + action_model, + collection_model, + service_model, + event_emitter + ): + """ + Creates a new method which makes a batch operation request + to the underlying service API. + """ + action = AioBatchAction(action_model) + + def batch_action(self, *args, **kwargs): + return action(self, *args, **kwargs) + + batch_action.__name__ = str(snake_cased) + batch_action.__doc__ = docstring.BatchActionDocstring( + resource_name=resource_name, + event_emitter=event_emitter, + batch_action_model=action_model, + service_model=service_model, + collection_model=collection_model, + include_signature=False + ) + return batch_action diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/factory.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/factory.py new file mode 100644 index 0000000000000000000000000000000000000000..886adb12c751d166c70f0339191cd9d27e3c30d9 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/factory.py @@ -0,0 +1,289 @@ +import logging +from functools import partial + +from boto3.resources.factory import ResourceFactory +from boto3.resources.model import ResourceModel +from boto3.resources.base import ResourceMeta +from boto3.docs import docstring +from boto3.exceptions import ResourceLoadException +from boto3.resources.factory import build_identifiers + +from aioboto3.resources.collection import AIOCollectionFactory +from aioboto3.resources.action import AIOServiceAction, AIOWaiterAction +from aioboto3.resources.base import AIOBoto3ServiceResource + +logger = logging.getLogger(__name__) + + +class AIOBoto3ResourceFactory(ResourceFactory): + # noinspection PyMissingConstructor + def __init__(self, emitter): + self._collection_factory = AIOCollectionFactory() + self._emitter = emitter + + async def load_from_definition(self, resource_name, + single_resource_json_definition, service_context): + logger.debug('Loading %s:%s', service_context.service_name, + resource_name) + + # Using the loaded JSON create a ResourceModel object. + resource_model = ResourceModel( + resource_name, + single_resource_json_definition, + service_context.resource_json_definitions + ) + + # Do some renaming of the shape if there was a naming collision + # that needed to be accounted for. + shape = None + if resource_model.shape: + shape = service_context.service_model.shape_for( + resource_model.shape + ) + resource_model.load_rename_map(shape) + + # Set some basic info + meta = ResourceMeta( + service_context.service_name, resource_model=resource_model) + attrs = { + 'meta': meta, + } + + # Create and load all of attributes of the resource class based + # on the models. + + # Identifiers + self._load_identifiers( + attrs=attrs, + meta=meta, + resource_name=resource_name, + resource_model=resource_model + ) + + # Load/Reload actions + self._load_actions( + attrs=attrs, + resource_name=resource_name, + resource_model=resource_model, + service_context=service_context + ) + + # Attributes that get auto-loaded + self._load_attributes( + attrs=attrs, + meta=meta, + resource_name=resource_name, + resource_model=resource_model, + service_context=service_context) + + # Collections and their corresponding methods + self._load_collections( + attrs=attrs, + resource_model=resource_model, + service_context=service_context) + + # References and Subresources + self._load_has_relations( + attrs=attrs, + resource_name=resource_name, + resource_model=resource_model, + service_context=service_context + ) + + # Waiter resource actions + self._load_waiters( + attrs=attrs, + resource_name=resource_name, + resource_model=resource_model, + service_context=service_context + ) + + # Create the name based on the requested service and resource + cls_name = resource_name + if service_context.service_name == resource_name: + cls_name = 'ServiceResource' + cls_name = service_context.service_name + '.' + cls_name + + base_classes = [AIOBoto3ServiceResource] + if self._emitter is not None: + await self._emitter.emit( + 'creating-resource-class.%s' % cls_name, + class_attributes=attrs, + base_classes=base_classes, + service_context=service_context + ) + return type(str(cls_name), tuple(base_classes), attrs) + + def _create_autoload_property( + factory_self, + resource_name, + name, + snake_cased, + member_model, + service_context + ): + """ + Creates a new property on the resource to lazy-load its value + via the resource's ``load`` method (if it exists). + """ + # The property loader will check to see if this resource has already + # been loaded and return the cached value if possible. If not, then + # it first checks to see if it CAN be loaded (raise if not), then + # calls the load before returning the value. + async def property_loader(self): + if self.meta.data is None: + if hasattr(self, 'load'): + await self.load() + else: + raise ResourceLoadException( + '{0} has no load method'.format( + self.__class__.__name__)) + + return self.meta.data.get(name) + + property_loader.__name__ = str(snake_cased) + property_loader.__doc__ = docstring.AttributeDocstring( + service_name=service_context.service_name, + resource_name=resource_name, + attr_name=snake_cased, + event_emitter=factory_self._emitter, + attr_model=member_model, + include_signature=False + ) + + return property(property_loader) + + def _create_waiter( + factory_self, resource_waiter_model, resource_name, service_context + ): + """ + Creates a new wait method for each resource where both a waiter and + resource model is defined. + """ + waiter = AIOWaiterAction( + resource_waiter_model, + waiter_resource_name=resource_waiter_model.name + ) + + async def do_waiter(self, *args, **kwargs): + await waiter(self, *args, **kwargs) + + do_waiter.__name__ = str(resource_waiter_model.name) + do_waiter.__doc__ = docstring.ResourceWaiterDocstring( + resource_name=resource_name, + event_emitter=factory_self._emitter, + service_model=service_context.service_model, + resource_waiter_model=resource_waiter_model, + service_waiter_model=service_context.service_waiter_model, + include_signature=False + ) + return do_waiter + + def _create_class_partial( + factory_self, subresource_model, resource_name, service_context + ): + """ + Creates a new method which acts as a functools.partial, passing + along the instance's low-level `client` to the new resource + class' constructor. + """ + name = subresource_model.resource.type + + async def create_resource(self, *args, **kwargs): + # We need a new method here because we want access to the + # instance's client. + positional_args = [] + + # We lazy-load the class to handle circular references. + json_def = service_context.resource_json_definitions.get(name, {}) + resource_cls = await factory_self.load_from_definition( + resource_name=name, + single_resource_json_definition=json_def, + service_context=service_context + ) + + # Assumes that identifiers are in order, which lets you do + # e.g. ``sqs.Queue('foo').Message('bar')`` to create a new message + # linked with the ``foo`` queue and which has a ``bar`` receipt + # handle. If we did kwargs here then future positional arguments + # would lead to failure. + identifiers = subresource_model.resource.identifiers + if identifiers is not None: + for identifier, value in build_identifiers(identifiers, self): + positional_args.append(value) + + return partial( + resource_cls, *positional_args, client=self.meta.client + )(*args, **kwargs) + + create_resource.__name__ = str(name) + create_resource.__doc__ = docstring.SubResourceDocstring( + resource_name=resource_name, + sub_resource_model=subresource_model, + service_model=service_context.service_model, + include_signature=False + ) + return create_resource + + def _create_action( + factory_self, + action_model, + resource_name, + service_context, + is_load=False + ): + """ + Creates a new method which makes a request to the underlying + AWS service. + """ + # Create the action in in this closure but before the ``do_action`` + # method below is invoked, which allows instances of the resource + # to share the ServiceAction instance. + action = AIOServiceAction( + action_model, factory=factory_self, service_context=service_context + ) + + # A resource's ``load`` method is special because it sets + # values on the resource instead of returning the response. + if is_load: + # We need a new method here because we want access to the + # instance via ``self``. + async def do_action(self, *args, **kwargs): + response = await action(self, *args, **kwargs) + self.meta.data = response + + # Create the docstring for the load/reload mehtods. + lazy_docstring = docstring.LoadReloadDocstring( + action_name=action_model.name, + resource_name=resource_name, + event_emitter=factory_self._emitter, + load_model=action_model, + service_model=service_context.service_model, + include_signature=False + ) + else: + # We need a new method here because we want access to the + # instance via ``self``. + async def do_action(self, *args, **kwargs): + response = await action(self, *args, **kwargs) + + if hasattr(self, 'load'): + # Clear cached data. It will be reloaded the next + # time that an attribute is accessed. + # TODO: Make this configurable in the future? + self.meta.data = None + + return response + + lazy_docstring = docstring.ActionDocstring( + resource_name=resource_name, + event_emitter=factory_self._emitter, + action_model=action_model, + service_model=service_context.service_model, + include_signature=False + ) + + do_action.__name__ = str(action_model.name) + do_action.__doc__ = lazy_docstring + return do_action + diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/response.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/response.py new file mode 100644 index 0000000000000000000000000000000000000000..6db654eccdc4333378b6c12d61daff7c85e42dd2 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/resources/response.py @@ -0,0 +1,92 @@ +from boto3.resources.response import RawHandler, ResourceHandler, build_identifiers, build_empty_response, all_not_none, jmespath + + +class AIOResourceHandler(ResourceHandler): + async def __call__(self, parent, params, response): + """ + :type parent: ServiceResource + :param parent: The resource instance to which this action is attached. + :type params: dict + :param params: Request parameters sent to the service. + :type response: dict + :param response: Low-level operation response. + """ + resource_name = self.resource_model.type + json_definition = self.service_context.resource_json_definitions.get( + resource_name + ) + + # Load the new resource class that will result from this action. + resource_cls = await self.factory.load_from_definition( + resource_name=resource_name, + single_resource_json_definition=json_definition, + service_context=self.service_context + ) + raw_response = response + search_response = None + + # Anytime a path is defined, it means the response contains the + # resource's attributes, so resource_data gets set here. It + # eventually ends up in resource.meta.data, which is where + # the attribute properties look for data. + if self.search_path: + search_response = jmespath.search(self.search_path, raw_response) + + # First, we parse all the identifiers, then create the individual + # response resources using them. Any identifiers that are lists + # will have one item consumed from the front of the list for each + # resource that is instantiated. Items which are not a list will + # be set as the same value on each new resource instance. + identifiers = dict( + build_identifiers( + self.resource_model.identifiers, parent, params, raw_response + ) + ) + + # If any of the identifiers is a list, then the response is plural + plural = [v for v in identifiers.values() if isinstance(v, list)] + + if plural: + response = [] + + # The number of items in an identifier that is a list will + # determine how many resource instances to create. + for i in range(len(plural[0])): + # Response item data is *only* available if a search path + # was given. This prevents accidentally loading unrelated + # data that may be in the response. + response_item = None + if search_response: + response_item = search_response[i] + response.append( + self.handle_response_item( + resource_cls, parent, identifiers, response_item + ) + ) + elif all_not_none(identifiers.values()): + # All identifiers must always exist, otherwise the resource + # cannot be instantiated. + response = self.handle_response_item( + resource_cls, parent, identifiers, search_response + ) + else: + # The response should be empty, but that may mean an + # empty dict, list, or None based on whether we make + # a remote service call and what shape it is expected + # to return. + response = None + if self.operation_name is not None: + # A remote service call was made, so try and determine + # its shape. + response = build_empty_response( + self.search_path, + self.operation_name, + self.service_context.service_model + ) + + return response + + +class AIORawHandler(RawHandler): + async def __call__(self, parent, params, response): + return super(AIORawHandler, self).__call__(parent, params, response) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__init__.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8afef61637d6e089e7d547aa4cc768c3580e0d89 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/cse.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/cse.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ece9efa6b95c6902bab1f4a5399bf3887cdad4bf Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/cse.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/inject.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/inject.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a9d17094e8ad4eeaccc7d9a1e0a9c73626764be7 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/__pycache__/inject.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/cse.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/cse.py new file mode 100644 index 0000000000000000000000000000000000000000..412acb3109656ce1a0ca395a005ca3456c89cee1 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/cse.py @@ -0,0 +1,614 @@ +import asyncio +import base64 +import json +import inspect +import os +import re +import sys +import struct +from io import BytesIO +from typing import Dict, Union, IO, Optional, Any, Tuple + +import aioboto3 +from cryptography.hazmat.primitives.ciphers.aead import AESGCM +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives.ciphers import Cipher +from cryptography.hazmat.primitives.ciphers.algorithms import AES +from cryptography.hazmat.primitives.ciphers.modes import CBC, CTR, ECB +from cryptography.hazmat.primitives.padding import PKCS7 +from cryptography.exceptions import InvalidTag +from cryptography.hazmat.primitives.asymmetric import padding +from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes, PublicKeyTypes +from cryptography.hazmat.primitives import serialization + + +RANGE_REGEX = re.compile(r'bytes=(?P\d+)-(?P\d+)*') +AES_BLOCK_SIZE = 128 +AES_BLOCK_SIZE_BYTES = 16 +JAVA_LONG_MAX_VALUE = 9223372036854775807 + + +# Just so it looks like the object aiohttp returns +class DummyAIOFile(object): + """So that response['Body'].read() presents the same way as a normal S3 get""" + + def __init__(self, data: bytes): + self.file = BytesIO(data) + + async def read(self, n=-1): + return self.file.read(n) + + async def readany(self): + return self.file.read() + + async def readexactly(self, n): + return self.file.read(n) + + async def readchunk(self): + return self.file.read(), True + + +class DecryptError(Exception): + pass + + +class CryptoContext(object): + async def setup(self): + """ + Coroutine to perform any setup + """ + pass + + async def close(self): + """ + Coroutine to perform any teardown + """ + + async def get_decryption_aes_key(self, key: bytes, material_description: Dict[str, Any]) -> bytes: + """ + Get decryption key for a given S3 object + + :param key: Base64 decoded version of x-amz-key-v2 + :param material_description: JSON decoded x-amz-matdesc + :return: Raw AES key bytes + """ + raise NotImplementedError() + + async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: + """ + Get encryption key to encrypt an S3 object + + :return: Raw AES key bytes, Stringified JSON x-amz-matdesc, Base64 encoded x-amz-key-v2 + """ + raise NotImplementedError() + + +class AsymmetricCryptoContext(CryptoContext): + """ + Crypto context which uses public-private key cryptography. + + The public and private keys need to be loaded in by ``cryptography.hazmat.primitives.serialization.*`` + + :param public_key: Public key object + :param private_key: Private key object + :param loop: Event loop + """ + + def __init__(self, public_key: Optional[PublicKeyTypes] = None, + private_key: Optional[PrivateKeyTypes] = None, loop: Optional[asyncio.AbstractEventLoop] = None): + + self.public_key = public_key + self.private_key = private_key + + self._loop = loop + if not loop: + self._loop = asyncio.get_event_loop() + + async def get_decryption_aes_key(self, key: bytes, material_description: Dict[str, Any]) -> bytes: + """ + Get decryption key for a given S3 object + + :param key: Base64 decoded version of x-amz-key + :param material_description: JSON decoded x-amz-matdesc + :return: Raw AES key bytes + """ + if self.private_key is None: + raise ValueError('Private key not provided during initialisation, cannot decrypt key encrypting key') + + plaintext = await self._loop.run_in_executor(None, lambda: (self.private_key.decrypt(key, padding.PKCS1v15()))) + + return plaintext + + async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: + """ + Get encryption key to encrypt an S3 object + + :return: Raw AES key bytes, Stringified JSON x-amz-matdesc, Base64 encoded x-amz-key + """ + if self.public_key is None: + raise ValueError('Public key not provided during initialisation, cannot encrypt key encrypting key') + + random_bytes = os.urandom(32) + + ciphertext = await self._loop.run_in_executor( + None, lambda: (self.public_key.encrypt(random_bytes, padding.PKCS1v15()))) + + return random_bytes, {}, base64.b64encode(ciphertext).decode() + + @staticmethod + def from_der_public_key(data: bytes) -> PublicKeyTypes: + """ + Convert public key in DER encoding to a Public key object + + :param data: public key bytes + """ + + return serialization.load_der_public_key(data, default_backend()) + + @staticmethod + def from_der_private_key(data: bytes, password: Optional[str] = None) -> PrivateKeyTypes: + """ + Convert private key in DER encoding to a Private key object + + :param data: private key bytes + :param password: password the private key is encrypted with + """ + return serialization.load_der_private_key(data, password, default_backend()) + + +class SymmetricCryptoContext(CryptoContext): + """ + Crypto context which uses symmetric cryptography. + + The key field should be a valid AES key. + + :param key: Key bytes + :param loop: Event loop + """ + + def __init__(self, key: bytes, loop: Optional[asyncio.AbstractEventLoop] = None): + self.key = key + self._backend = default_backend() + self._cipher = Cipher(AES(self.key), ECB(), backend=self._backend) + + self._loop = loop + if not loop: + self._loop = asyncio.get_event_loop() + + async def get_decryption_aes_key(self, key: bytes, material_description: Dict[str, Any]) -> bytes: + """ + Get decryption key for a given S3 object + + :param key: Base64 decoded version of x-amz-key + :param material_description: JSON decoded x-amz-matdesc + :return: Raw AES key bytes + """ + + # So it seems when java just calls Cipher.getInstance('AES') it'll default to AES/ECB/PKCS5Padding + aesecb = self._cipher.decryptor() + padded_result = await self._loop.run_in_executor(None, lambda: (aesecb.update(key) + aesecb.finalize())) + + unpadder = PKCS7(AES.block_size).unpadder() + result = await self._loop.run_in_executor(None, lambda: (unpadder.update(padded_result) + unpadder.finalize())) + + return result + + async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: + """ + Get encryption key to encrypt an S3 object + + :return: Raw AES key bytes, Stringified JSON x-amz-matdesc, Base64 encoded x-amz-key + """ + + random_bytes = os.urandom(32) + + padder = PKCS7(AES.block_size).padder() + padded_result = await self._loop.run_in_executor( + None, lambda: (padder.update(random_bytes) + padder.finalize())) + + aesecb = self._cipher.encryptor() + encrypted_result = await self._loop.run_in_executor( + None, lambda: (aesecb.update(padded_result) + aesecb.finalize())) + + return random_bytes, {}, base64.b64encode(encrypted_result).decode() + + +class KMSCryptoContext(CryptoContext): + """ + Crypto context which uses symmetric cryptography. + + The key field should be a valid AES key. + + E.g. if you wanted to set the KMS region, add kms_client_args={'region_name': 'eu-west-1'} + + :param key: Key bytes + :param kms_client_args: Will be expanded when getting a KMS client + :param authenticated_encryption: Uses AES-GCM instead of AES-CBC (also allows range gets of files) + :param loop: Event loop + """ + + def __init__(self, keyid: Optional[str] = None, kms_client_args: Optional[dict] = None, + authenticated_encryption: bool = True): + self.kms_key = keyid + self.authenticated_encryption = authenticated_encryption + + # Store the client instead of creating one every time, performance wins when doing many files + self._kms_client = None + self._kms_client_args = kms_client_args if kms_client_args else {} + self._session = None + + async def setup(self): + self._session = aioboto3.Session() + self._kms_client = await self._session.client('kms', **self._kms_client_args).__aenter__() + + async def close(self): + await self._kms_client.close() + + async def get_decryption_aes_key(self, key: bytes, material_description: Dict[str, Any]) -> bytes: + kms_data = await self._kms_client.decrypt( + CiphertextBlob=key, + EncryptionContext=material_description + ) + return kms_data['Plaintext'] + + async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: + if self.kms_key is None: + raise ValueError('KMS Key not provided during initalisation, cannot decrypt key encrypting key') + + encryption_context = {'kms_cmk_id': self.kms_key} + kms_resp = await self._kms_client.generate_data_key( + KeyId=self.kms_key, + EncryptionContext=encryption_context, + KeySpec='AES_256' + ) + + return kms_resp['Plaintext'], encryption_context, base64.b64encode(kms_resp['CiphertextBlob']).decode() + + +class MockKMSCryptoContext(KMSCryptoContext): + def __init__(self, aes_key: bytes, material_description: dict, encrypted_key: bytes, + authenticated_encryption: bool = True): + super(MockKMSCryptoContext, self).__init__() + self.aes_key = aes_key + self.material_description = material_description + self.encrypted_key = encrypted_key + self.authenticated_encryption = authenticated_encryption + + async def setup(self): + pass + + async def close(self): + pass + + async def get_decryption_aes_key(self, key: bytes, material_description: Dict[str, Any]) -> bytes: + return self.aes_key + + async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: + return self.aes_key, self.material_description.copy(), base64.b64encode(self.encrypted_key).decode() + + +class S3CSE(object): + """ + S3 Client-side encryption wrapper. + + To change S3 region add s3_client_args={'region_name': 'eu-west-1'} + + To use this object, either use it with ``async with S3CSE(...) as s3_cse:`` + Or run the setup() and close() coro's respectively + + :param crypto_context: Takes a cryto context object from above + :param s3_client_args: Optional dict of S3 client args + """ + + def __init__(self, crypto_context: CryptoContext, s3_client_args: Optional[dict] = None): + self._loop = None + self._backend = default_backend() + + self._crypto_context = crypto_context + self._session = None + self._s3_client = None + self._s3_client_args = s3_client_args if s3_client_args else {} + + async def setup(self): + if sys.version_info < (3, 7): + self._loop = asyncio.get_event_loop() + else: + self._loop = asyncio.get_running_loop() + + self._session = aioboto3.Session() + self._s3_client = await self._session.client('s3', **self._s3_client_args).__aenter__() + await self._crypto_context.setup() + + async def close(self): + await self._s3_client.close() + await self._crypto_context.close() + + async def __aenter__(self): + await self.setup() + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + await self.close() + + # noinspection PyPep8Naming + async def get_object(self, Bucket: str, Key: str, **kwargs) -> dict: + """ + S3 GetObject. Takes same args as Boto3 documentation + + Decrypts any CSE + + :param Bucket: S3 Bucket + :param Key: S3 Key (filepath) + :return: returns same response as a normal S3 get_object + """ + if self._s3_client is None: + await self.setup() + + # Ok so if we are doing a range get. We need to align the range start/end with AES block boundaries + # 9223372036854775806 is 8EiB so I have no issue with hardcoding it. + # We pass the actual start, desired start and desired end to the decrypt function so that it can + # generate the correct IV's for starting decryption at that block and then chop off the start and end of the + # AES block so it matches what the user is expecting. + _range = kwargs.get('Range') + actual_range_start = None + desired_range_start = None + desired_range_end = None + if _range: + range_match = RANGE_REGEX.match(_range) + if not range_match: + raise ValueError('Dont understand this range value {0}'.format(_range)) + + desired_range_start = int(range_match.group(1)) + desired_range_end = range_match.group(2) + if desired_range_end is None: + desired_range_end = 9223372036854775806 + else: + desired_range_end = int(desired_range_end) + + actual_range_start, actual_range_end = _get_adjusted_crypto_range(desired_range_start, desired_range_end) + + # Update range with actual start_end + kwargs['Range'] = 'bytes={0}-{1}'.format(actual_range_start, actual_range_end) + + s3_response = await self._s3_client.get_object(Bucket=Bucket, Key=Key, **kwargs) + metadata = s3_response['Metadata'] + whole_file_length = int(s3_response['ResponseMetadata']['HTTPHeaders']['content-length']) + + if 'x-amz-key' not in metadata and 'x-amz-key-v2' not in metadata: + # No crypto + return s3_response + + if 'x-amz-key' in metadata: + # Crypto V1 + # Todo move the file obj into the decrypt to do streaming + file_data = await s3_response['Body'].read() + body = await self._decrypt_v1(file_data, metadata, actual_range_start) + else: + # Crypto V2 + # Todo move the file obj into the decrypt to do streaming + file_data = await s3_response['Body'].read() + body = await self._decrypt_v2(file_data, metadata, whole_file_length, + actual_range_start, desired_range_start, + desired_range_end) + + s3_response['Body'] = DummyAIOFile(body) + + return s3_response + + async def _decrypt_v1(self, file_data: bytes, metadata: Dict[str, str], range_start: Optional[int] = None) -> bytes: + if range_start: + raise DecryptError('Cant do range get when not using KMS encryption') + + decryption_key = base64.b64decode(metadata['x-amz-key']) + material_description = json.loads(metadata['x-amz-matdesc']) + + aes_key = await self._crypto_context.get_decryption_aes_key(decryption_key, material_description) + + # x-amz-key - Contains base64 encrypted key + # x-amz-iv - AES IVs + # x-amz-matdesc - JSON Description of client-side master key (used as encryption context as is) + # x-amz-unencrypted-content-length - Unencrypted content length + + iv = base64.b64decode(metadata['x-amz-iv']) + + # TODO look at doing AES as stream + + # AES/CBC/PKCS5Padding + aescbc = Cipher(AES(aes_key), CBC(iv), backend=self._backend).decryptor() + padded_result = await self._loop.run_in_executor(None, lambda: (aescbc.update(file_data) + aescbc.finalize())) + + unpadder = PKCS7(AES.block_size).unpadder() + result = await self._loop.run_in_executor(None, lambda: (unpadder.update(padded_result) + unpadder.finalize())) + + return result + + async def _decrypt_v2(self, file_data: bytes, metadata: Dict[str, str], entire_file_length: int, + range_start: Optional[int] = None, desired_start: Optional[int] = None, + desired_end: Optional[int] = None) -> bytes: + + decryption_key = base64.b64decode(metadata['x-amz-key-v2']) + material_description = json.loads(metadata['x-amz-matdesc']) + + aes_key = await self._crypto_context.get_decryption_aes_key(decryption_key, material_description) + + # x-amz-key-v2 - Contains base64 encrypted key + # x-amz-iv - AES IVs + # x-amz-matdesc - JSON Description of client-side master key (used as encryption context as is) + # x-amz-unencrypted-content-length - Unencrypted content length + # x-amz-wrap-alg - Key wrapping algo, either AESWrap, RSA/ECB/OAEPWithSHA-256AndMGF1Padding or KMS + # x-amz-cek-alg - AES/GCM/NoPadding or AES/CBC/PKCS5Padding + # x-amz-tag-len - AEAD Tag length in bits + + iv = base64.b64decode(metadata['x-amz-iv']) + + # TODO look at doing AES as stream + if metadata.get('x-amz-cek-alg', 'AES/CBC/PKCS5Padding') == 'AES/GCM/NoPadding': + # AES/GCM/NoPadding + + # So begin the nastyness + if range_start is not None: + # Generate IV's as if you were doing so for each block until we get to the one we need + iv = _adjust_iv_for_range(iv, range_start) + # IV is now 16 bytes not 12 + + aesctr = Cipher(AES(aes_key), CTR(iv), backend=self._backend).decryptor() + + result = await self._loop.run_in_executor(None, lambda: (aesctr.update(file_data) + aesctr.finalize())) + + # Possible remove AEAD tag if our range covers the end + aead_tag_len = int(metadata['x-amz-tag-len']) // 8 + max_offset = entire_file_length - aead_tag_len - 1 + desired_end = max_offset if desired_end > max_offset else desired_end + + # Chop file + result = result[desired_start:desired_end] + + else: + aesgcm = AESGCM(aes_key) + + try: + result = await self._loop.run_in_executor(None, lambda: aesgcm.decrypt(iv, file_data, None)) + except InvalidTag: + raise DecryptError('Failed to decrypt, AEAD tag is incorrect. Possible key or IV are incorrect') + + else: + if range_start: + raise DecryptError('Cannot decrypt AES-CBC file with range') + + # AES/CBC/PKCS5Padding + aescbc = Cipher(AES(aes_key), CBC(iv), backend=self._backend).decryptor() + padded_result = await self._loop.run_in_executor( + None, lambda: (aescbc.update(file_data) + aescbc.finalize())) + + unpadder = PKCS7(AES.block_size).unpadder() + result = await self._loop.run_in_executor( + None, lambda: (unpadder.update(padded_result) + unpadder.finalize())) + + return result + + async def put_object(self, Body: Union[bytes, IO], Bucket: str, Key: str, Metadata: Dict = None, **kwargs): + """ + PutObject. Takes same args as Boto3 documentation + + Encrypts files + + :param: Body: File data + :param Bucket: S3 Bucket + :param Key: S3 Key (filepath) + """ + if self._s3_client is None: + await self.setup() + + if hasattr(Body, 'read'): + if inspect.iscoroutinefunction(Body.read): + Body = await Body.read() + else: + Body = Body.read() + + # We do some different V2 stuff if using kms + is_kms = isinstance(self._crypto_context, KMSCryptoContext) + # noinspection PyUnresolvedReferences + authenticated_crypto = is_kms and self._crypto_context.authenticated_encryption + + Metadata = Metadata if Metadata is not None else {} + + aes_key, matdesc_metadata, key_metadata = await self._crypto_context.get_encryption_aes_key() + + if is_kms and authenticated_crypto: + Metadata['x-amz-cek-alg'] = 'AES/GCM/NoPadding' + Metadata['x-amz-tag-len'] = str(AES_BLOCK_SIZE) + iv = os.urandom(12) + + # 16byte 128bit authentication tag forced + aesgcm = AESGCM(aes_key) + + result = await self._loop.run_in_executor(None, lambda: aesgcm.encrypt(iv, Body, None)) + + else: + if is_kms: # V1 is always AES/CBC/PKCS5Padding + Metadata['x-amz-cek-alg'] = 'AES/CBC/PKCS5Padding' + + iv = os.urandom(16) + + padder = PKCS7(AES.block_size).padder() + padded_result = await self._loop.run_in_executor(None, lambda: (padder.update(Body) + padder.finalize())) + + aescbc = Cipher(AES(aes_key), CBC(iv), backend=self._backend).encryptor() + result = await self._loop.run_in_executor(None, lambda: (aescbc.update(padded_result) + aescbc.finalize())) + + # For all V1 and V2 + Metadata['x-amz-unencrypted-content-length'] = str(len(Body)) + Metadata['x-amz-iv'] = base64.b64encode(iv).decode() + Metadata['x-amz-matdesc'] = json.dumps(matdesc_metadata) + + if is_kms: + Metadata['x-amz-wrap-alg'] = 'kms' + Metadata['x-amz-key-v2'] = key_metadata + else: + Metadata['x-amz-key'] = key_metadata + + await self._s3_client.put_object( + Bucket=Bucket, + Key=Key, + Body=result, + Metadata=Metadata, + **kwargs + ) + + +def _adjust_iv_for_range(iv: bytes, byte_offset: int) -> bytes: + if len(iv) != 12: + raise RuntimeError('IV must be 12 bytes long for AES-GCM/CTR') + + block_size = AES_BLOCK_SIZE + block_offset = byte_offset // block_size + if block_offset * block_size != byte_offset: + raise RuntimeError('Range size invalid. Should never hit this as range should be adjusted by now') + + j0 = _compute_j0(iv) + return _increment_blocks(j0, block_offset) + + +def _get_adjusted_crypto_range(start: int, end: int) -> Tuple[int, int]: + start = _get_cipher_block_lower_bound(start) + end = _get_cipher_block_upper_bound(end) # Copied from teh JAVA + + return start, end + + +def _get_cipher_block_lower_bound(value: int) -> int: + lower_bound = value - (value % AES_BLOCK_SIZE) - AES_BLOCK_SIZE + return max(lower_bound, 0) + + +def _get_cipher_block_upper_bound(value: int) -> int: + offset = AES_BLOCK_SIZE - (value % AES_BLOCK_SIZE) + upper_bound = value + offset + AES_BLOCK_SIZE + return min(upper_bound, JAVA_LONG_MAX_VALUE) + + +def _compute_j0(iv: bytes) -> bytes: + j0 = iv + (b'\x00' * (AES_BLOCK_SIZE_BYTES - 13)) + b'\x01' # iv must be of length 12 + + return _increment_blocks(j0, 1) + + +def _increment_blocks(counter: bytes, block_delta: int) -> bytes: + if block_delta == 0: + return counter + + if not counter or len(counter) != 16: + raise ValueError('Counter must be 16 bytes long') + + byte_buffer = [0] * 8 + + i = 12 + while i <= 15: + byte_buffer[i-8] = counter[i] + i += 1 + + result = struct.pack('>Q', struct.unpack('>Q', bytes(byte_buffer))[0] + block_delta) + + counter = counter[:12] + result[4:8] + + return counter diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/inject.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/inject.py new file mode 100644 index 0000000000000000000000000000000000000000..8fa882f7828d6ec9e784c16b2a18275ee96dda47 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/aioboto3/s3/inject.py @@ -0,0 +1,732 @@ +import asyncio +import aiofiles +import inspect +import logging +import math +from functools import partial +from io import BytesIO +from typing import Optional, Callable, BinaryIO, Dict, Any, Union +from abc import abstractmethod + +from aiobotocore.context import with_current_context +from botocore.exceptions import ClientError +from botocore.useragent import register_feature_id +from boto3 import utils +from boto3.s3.transfer import S3TransferConfig, S3Transfer +from boto3.s3.inject import bucket_upload_file, bucket_download_file, bucket_copy, bucket_upload_fileobj, bucket_download_fileobj +from s3transfer.upload import UploadSubmissionTask +from s3transfer.copies import CopySubmissionTask + +logger = logging.getLogger(__name__) + + +TransferCallback = Callable[[int], None] + + +class _AsyncBinaryIO: + @abstractmethod + async def seek(self, offset: int, whence: int = 0) -> int: + pass + + @abstractmethod + async def write(self, s: Union[bytes, bytearray]) -> int: + pass + + +AnyFileObject = Union[_AsyncBinaryIO, BinaryIO] + + +def inject_s3_transfer_methods(class_attributes, **kwargs): + utils.inject_attribute(class_attributes, 'upload_file', upload_file) + utils.inject_attribute(class_attributes, 'download_file', download_file) + utils.inject_attribute(class_attributes, 'copy', copy) + utils.inject_attribute(class_attributes, 'upload_fileobj', upload_fileobj) + utils.inject_attribute( + class_attributes, 'download_fileobj', download_fileobj + ) + + +def inject_object_summary_methods(class_attributes, **kwargs): + utils.inject_attribute(class_attributes, 'load', object_summary_load) + + +def inject_bucket_methods(class_attributes, **kwargs): + utils.inject_attribute(class_attributes, 'load', bucket_load) + utils.inject_attribute(class_attributes, 'upload_file', bucket_upload_file) + utils.inject_attribute( + class_attributes, 'download_file', bucket_download_file + ) + utils.inject_attribute(class_attributes, 'copy', bucket_copy) + utils.inject_attribute( + class_attributes, 'upload_fileobj', bucket_upload_fileobj + ) + utils.inject_attribute( + class_attributes, 'download_fileobj', bucket_download_fileobj + ) + + +async def object_summary_load(self, *args, **kwargs): + response = await self.meta.client.head_object( + Bucket=self.bucket_name, Key=self.key + ) + if 'ContentLength' in response: + response['Size'] = response.pop('ContentLength') + self.meta.data = response + + +@with_current_context(partial(register_feature_id, 'S3_TRANSFER')) +async def download_file( + self, + Bucket: str, + Key: str, + Filename: str, + ExtraArgs: Optional[Dict[str, Any]] = None, + Callback: Optional[TransferCallback] = None, + Config: Optional[S3TransferConfig] = None +): + """Download an S3 object to a file asynchronously. + + Usage:: + + import aioboto3 + + async with aioboto3.resource('s3') as s3: + await s3.meta.client.download_file('mybucket', 'hello.txt', '/tmp/hello.txt') + + Similar behaviour as S3Transfer's download_file() method, + except that parameters are capitalised. + """ + async with aiofiles.open(Filename, 'wb') as fileobj: # type: _AsyncBinaryIO + await download_fileobj( + self, + Bucket, + Key, + fileobj, + ExtraArgs=ExtraArgs, + Callback=Callback, + Config=Config + ) + + +async def _download_part(self, bucket: str, key: str, extraArgs: Dict[str, str], headers: Dict[str, str], start: int, file: AnyFileObject, semaphore: asyncio.Semaphore, write_lock: asyncio.Lock, + callback=None, io_queue: Optional[asyncio.Queue] = None) -> None: + async with semaphore: # limit number of concurrent downloads + response = await self.get_object( + Bucket=bucket, Key=key, Range=headers['Range'], **extraArgs + ) + content = await response['Body'].read() + + # If stream is not seekable, return the offset and data so it can be queued up to be written + if io_queue: + await io_queue.put((start, content)) + else: + # Check if it's aiofiles file + if inspect.iscoroutinefunction(file.seek) and inspect.iscoroutinefunction(file.write): + # These operations need to happen sequentially, which is non-deterministic when dealing with event loops + async with write_lock: + await file.seek(start) + await file.write(content) + else: + # Fallback to synchronous operations for file objects that are not async + file.seek(start) + file.write(content) + + # Call the wrapper callback with the number of bytes written, if provided + if callback: + try: + callback(len(content)) + except: # noqa: E722 + pass + + +@with_current_context(partial(register_feature_id, 'S3_TRANSFER')) +async def download_fileobj( + self, + Bucket: str, + Key: str, + Fileobj: AnyFileObject, + ExtraArgs: Optional[Dict[str, Any]] = None, + Callback: Optional[TransferCallback] = None, + Config: Optional[S3TransferConfig] = None +): + """Download an object from S3 to a file-like object. + + The file-like object must be in binary mode. + + This is a managed transfer which will perform a multipart download + with asyncio if necessary. + + Usage:: + + import aioboto3 + s3 = aioboto3.client('s3') + + async with aiofiles.open('filename', 'wb') as data: + await s3.download_fileobj('mybucket', 'mykey', data) + + :type Fileobj: a file-like object + :param Fileobj: A file-like object to download into. At a minimum, it must + implement the `write` method and must accept bytes. + + :type Bucket: str + :param Bucket: The name of the bucket to download from. + + :type Key: str + :param Key: The name of the key to download from. + + :type ExtraArgs: dict + :param ExtraArgs: Extra arguments that may be passed to the + client operation. + + :type Callback: method + :param Callback: A method which takes a number of bytes transferred to + be periodically called during the download. + + :type Config: boto3.s3.transfer.TransferConfig + :param Config: The transfer configuration to be used when performing the + download. + """ + + Config = Config or S3TransferConfig() + ExtraArgs = ExtraArgs or {} + + try: + # Get object metadata to determine the total size + head_response = await self.head_object(Bucket=Bucket, Key=Key, **ExtraArgs) + except ClientError as err: + if err.response['Error']['Code'] == 'NoSuchKey': + # Convert to 404 so it looks the same when boto3.download_file fails + raise ClientError({'Error': {'Code': '404', 'Message': 'Not Found'}}, 'HeadObject') + raise + + # Semaphore to limit the number of concurrent downloads + semaphore = asyncio.Semaphore(Config.max_request_concurrency) + write_mutex = asyncio.Lock() + + total_size = head_response['ContentLength'] + total_parts = (total_size + Config.multipart_chunksize - 1) // Config.multipart_chunksize + + # Keep track of total downloaded bytes + total_downloaded = 0 + + def wrapper_callback(bytes_transferred): + nonlocal total_downloaded + total_downloaded += bytes_transferred + if Callback: + try: + Callback(total_downloaded) + except: # noqa: E722 + pass + + is_seekable = hasattr(Fileobj, "seek") + + # This'll have around `semaphore` length items, somewhat more if writing is slow + # TODO add limits so we dont fill up this list n blow out ram + io_list = [] + + # This should be Config.io_concurrency but as we're gathering all coro's we cant guarantee + # that the co-routines will start in relative order so we could fill up the queue with the + # x chunks and if we're not writing to a seekable stream then it'll deadlock. + io_queue = asyncio.Queue() + + async def queue_reader(): + """ + Pretty much, get things off queue, add them to list + Go through list, write things to file object in order + """ + is_async = inspect.iscoroutinefunction(Fileobj.write) + + try: + written_pos = 0 + while written_pos < total_size: + io_list.append(await io_queue.get()) + + # Stuff might be out of order in io_list + # so spin until there's nothing to queue off + done_nothing = False + while not done_nothing: + done_nothing = True + + indexes_to_remove = [] + for index, (chunk_start, data) in enumerate(io_list): + if chunk_start == written_pos: + if is_async: + await Fileobj.write(data) + else: + Fileobj.write(data) + + indexes_to_remove.append(index) + written_pos += len(data) + done_nothing = False + + for index in reversed(indexes_to_remove): + io_list.pop(index) + except asyncio.CancelledError: + pass + + queue_reader_future = None + if not is_seekable: + queue_reader_future = asyncio.ensure_future(queue_reader()) + + try: + tasks = [] + for i in range(total_parts): + start = i * Config.multipart_chunksize + end = min( + start + Config.multipart_chunksize, total_size + ) # Ensure we don't go beyond the total size + # Range headers, start at 0 so end which would be total_size, minus 1 = 0 indexed. + headers = {'Range': f'bytes={start}-{end - 1}'} + # Create a task for each part download + tasks.append( + _download_part(self, Bucket, Key, ExtraArgs, headers, start, Fileobj, semaphore, write_mutex, wrapper_callback, io_queue if not is_seekable else None) + ) + + # Run all the download tasks concurrently + await asyncio.gather(*tasks) # TODO might not be worth spamming the eventloop with 1000's of tasks, but deal with it when its a problem. + + if queue_reader_future: + await queue_reader_future + + logger.debug(f'Downloaded file from {Bucket}/{Key}') + + except ClientError as e: + raise Exception( + f"Couldn't download file from {Bucket}/{Key}" + ) from e + + +@with_current_context(partial(register_feature_id, 'S3_TRANSFER')) +async def upload_fileobj( + self, + Fileobj: AnyFileObject, + Bucket: str, + Key: str, + ExtraArgs: Optional[Dict[str, Any]] = None, + Callback: Optional[TransferCallback] = None, + Config: Optional[S3TransferConfig] = None, + Processing: Callable[[bytes], bytes] = None +): + """Upload a file-like object to S3. + + The file-like object must be in binary mode. + + This is a managed transfer which will perform a multipart upload in + multiple threads if necessary. + + Usage:: + + import aioboto3 + s3 = aioboto3.client('s3') + + async with aiofiles.open('filename', 'rb') as data: + await s3.upload_fileobj(data, 'mybucket', 'mykey') + + :type Fileobj: a file-like object + :param Fileobj: A file-like object to upload. At a minimum, it must + implement the `read` method, and must return bytes. + + :type Bucket: str + :param Bucket: The name of the bucket to upload to. + + :type Key: str + :param Key: The name of the key to upload to. + + :type ExtraArgs: dict + :param ExtraArgs: Extra arguments that may be passed to the + client operation. + + :type Callback: method + :param Callback: A method which takes a number of bytes transferred to + be periodically called during the upload. + + :type Config: boto3.s3.transfer.TransferConfig + :param Config: The transfer configuration to be used when performing the + upload. + + :type Processing: method + :param Processing: A method which takes a bytes buffer and convert it + by custom logic. + """ + kwargs = ExtraArgs or {} + upload_part_args = {k: v for k, v in kwargs.items() if k in UploadSubmissionTask.UPLOAD_PART_ARGS} + complete_upload_args = {k: v for k, v in kwargs.items() if k in UploadSubmissionTask.COMPLETE_MULTIPART_ARGS} + Config = Config or S3TransferConfig() + + async def fileobj_read(num_bytes: int) -> bytes: + data = Fileobj.read(num_bytes) + if inspect.isawaitable(data): + data = await data + else: + await asyncio.sleep(0.0) # Yield to the eventloop incase .read() took ages + + return data + + # So some streams might return less than Config.multipart_threshold on a read, but that might not be eof + initial_data = b'' + while len(initial_data) < Config.multipart_threshold: + new_data = await fileobj_read(Config.multipart_threshold) + if new_data == b'': + break + initial_data += new_data + + if len(initial_data) < Config.multipart_threshold: + # Do Processing hook here, else it'll happen during the multipart + # upload loop too + if Processing: + initial_data = Processing(initial_data) + + # Do put_object + await self.put_object( + Bucket=Bucket, + Key=Key, + Body=initial_data, + **kwargs + ) + if Callback: + if inspect.iscoroutinefunction(Callback): + await Callback(len(initial_data)) + else: + Callback(len(initial_data)) + return + + # File bigger than threshold, start multipart upload + resp = await self.create_multipart_upload(Bucket=Bucket, Key=Key, **kwargs) + upload_id = resp['UploadId'] + finished_parts = [] + expected_parts = 0 + io_queue = asyncio.Queue(maxsize=Config.max_io_queue_size) + exception_event = asyncio.Event() + exception = None + sent_bytes = 0 + + async def uploader() -> int: + nonlocal sent_bytes + nonlocal exception + uploaded_parts = 0 + + # Loop whilst no other co-routine has raised an exception + while not exception: + try: + part_args = await io_queue.get() + except asyncio.CancelledError: + break + + # Submit part to S3 + try: + resp = await self.upload_part(**part_args) + except Exception as err: + # Set the main exception variable to the current exception, trigger the exception event + exception = err + exception_event.set() + # Exit the coro + break + + # Success, add the result to the finished_parts, increment the sent_bytes + + finished_parts_kwargs = {} + if 'ChecksumAlgorithm' in kwargs: + for key in resp: + if key.startswith('Checksum'): + finished_parts_kwargs[key] = resp[key] + finished_parts.append( + {'ETag': resp['ETag'], 'PartNumber': part_args['PartNumber'], **finished_parts_kwargs}) + current_bytes = len(part_args['Body']) + sent_bytes += current_bytes + uploaded_parts += 1 + logger.debug('Uploaded part to S3') + + # Call the callback, if it blocks then not good :/ + if Callback: + try: + if inspect.iscoroutinefunction(Callback): + await Callback(current_bytes) + else: + Callback(current_bytes) + except: # noqa: E722 + pass + + # Mark task as done so .join() will work later on + io_queue.task_done() + + # For testing return number of parts uploaded + return uploaded_parts + + async def file_reader() -> None: + nonlocal expected_parts + nonlocal exception + part = 0 + eof = False + while not exception and not eof: + part += 1 + multipart_payload = bytearray() + if part == 1: # Add in the initial data we've read to check if we've met the multipart threshold + multipart_payload += initial_data + + loop_counter = 0 + while len(multipart_payload) < Config.multipart_chunksize: + try: + # Handles if .read() returns anything that can be awaited + data = await fileobj_read(Config.io_chunksize) + except Exception as err: + # Caught some random exception whilst reading from a file + exception = err + exception_event.set() + + # shortcircuit upload logic + eof = True + multipart_payload = bytearray() + break + + if data == b'' and loop_counter > 0: # End of file, handles uploading empty files + eof = True + break + multipart_payload += data + loop_counter += 1 + + # If file has ended but chunk has some data in it, upload it, + # else if file ended just after a chunk then exit + # if the first part is b'' then upload it as we're uploading an empty + # file + if not multipart_payload and part != 1: + break + + if Processing: + multipart_payload = Processing(multipart_payload) + + await io_queue.put({'Body': multipart_payload, 'Bucket': Bucket, 'Key': Key, + 'PartNumber': part, 'UploadId': upload_id, **upload_part_args}) + logger.debug('Added part to io_queue') + expected_parts += 1 + + file_reader_future = asyncio.ensure_future(file_reader()) + futures = [asyncio.ensure_future(uploader()) for _ in range(0, Config.max_request_concurrency)] + + # Wait for file reader to finish + try: + await file_reader_future + except Exception as err: + # if the file reader raises, we need to clean up the uploaders + exception = err + exception_event.set() + # So by this point all of the file is read and in a queue + + # wait for either io queue is finished, or an exception has been raised + _, pending = await asyncio.wait( + {asyncio.create_task(io_queue.join()), asyncio.create_task(exception_event.wait())}, + return_when=asyncio.FIRST_COMPLETED + ) + + if exception_event.is_set() or len(finished_parts) != expected_parts: + # An exception during upload or for some reason the finished parts dont match the expected parts, cancel upload + await self.abort_multipart_upload(Bucket=Bucket, Key=Key, UploadId=upload_id) + # Raise exception later after we've disposed of the pending co-routines + else: + # All io chunks from the queue have been successfully uploaded + try: + # Sort the finished parts as they must be in order + finished_parts.sort(key=lambda item: item['PartNumber']) + + await self.complete_multipart_upload( + Bucket=Bucket, + Key=Key, + UploadId=upload_id, + MultipartUpload={'Parts': finished_parts}, + **complete_upload_args + ) + except Exception as err: + # We failed to complete the upload, try and abort, then return the orginal error + exception = err + try: + await self.abort_multipart_upload(Bucket=Bucket, Key=Key, UploadId=upload_id) + except: + pass + + # Close either the Queue.join() coro, or the event.wait() coro + for coro in pending: + if not coro.done(): + coro.cancel() + try: + await coro + except: + pass + + # Cancel any remaining futures, though if successful they'll be done + cancelled = [] + for future in futures: + if not future.done(): + future.cancel() + cancelled.append(future) + else: + uploaded_parts = future.result() + logger.debug('Future uploaded {0} parts'.format(uploaded_parts)) + if cancelled: + for uploaded_parts in await asyncio.gather(*cancelled, return_exceptions=True): + if isinstance(uploaded_parts, int): + logger.debug('Future uploaded {0} parts'.format(uploaded_parts)) + + # Raise an exception now after everythings cleaned up + if exception: + raise exception + + +@with_current_context(partial(register_feature_id, 'S3_TRANSFER')) +async def upload_file( + self, + Filename: str, + Bucket: str, + Key: str, + ExtraArgs: Optional[Dict[str, Any]] = None, + Callback: Optional[TransferCallback] = None, + Config: Optional[S3TransferConfig] = None +): + """Upload a file to an S3 object. + + Usage:: + + import aioboto3 + async with aioboto3.resource('s3') as s3: + await s3.meta.client.upload_file('/tmp/hello.txt', 'mybucket', 'hello.txt') + + Similar behavior as S3Transfer's upload_file() method, + except that parameters are capitalized. + """ + async with aiofiles.open(Filename, 'rb') as open_file: + await upload_fileobj( + self, + open_file, + Bucket, + Key, + ExtraArgs=ExtraArgs, + Callback=Callback, + Config=Config + ) + + +@with_current_context(partial(register_feature_id, 'S3_TRANSFER')) +async def copy( + self, + CopySource: Dict[str, Any], + Bucket: str, + Key: str, + ExtraArgs: Optional[Dict[str, Any]] = None, + Callback: Optional[TransferCallback] = None, + SourceClient=None, # Should be aioboto3/aiobotocore client + Config: Optional[S3TransferConfig] = None +): + assert 'Bucket' in CopySource + assert 'Key' in CopySource + + SourceClient = SourceClient or self + Config = Config or S3TransferConfig() + ExtraArgs = ExtraArgs or {} + + try: + head_object_kwargs = {} + for param, value in ExtraArgs.items(): + if param in CopySubmissionTask.EXTRA_ARGS_TO_HEAD_ARGS_MAPPING: + head_object_kwargs[CopySubmissionTask.EXTRA_ARGS_TO_HEAD_ARGS_MAPPING[param]] = value + + # Get object metadata to determine the total size + head_response = await SourceClient.head_object(Bucket=CopySource['Bucket'], Key=CopySource['Key'], **head_object_kwargs) + except ClientError as err: + if err.response['Error']['Code'] == 'NoSuchKey': + # Convert to 404 so it looks the same when boto3.download_file fails + raise ClientError({'Error': {'Code': '404', 'Message': 'Not Found'}}, 'HeadObject') + raise + + # So CopyObject works up to 5GiB, but S3Transfer uses Config.MultipartThreshold which by default is 8MiB :unamused: + if head_response['ContentLength'] < Config.multipart_threshold: + await self.copy_object(CopySource=CopySource, Bucket=Bucket, Key=Key, **ExtraArgs) + return + + # File is larger than 5GiB, do multipart copy + create_multipart_kwargs = {k: v for k, v in ExtraArgs.items() if k not in CopySubmissionTask.CREATE_MULTIPART_ARGS_BLACKLIST} + create_multipart_upload_resp = await self.create_multipart_upload(Bucket=Bucket, Key=Key, **create_multipart_kwargs) + + finished_parts = [] + total_size = 0 + + sem = asyncio.Semaphore(Config.max_request_concurrency) + + async def uploader(size: int, part_args: Dict[str, Any]): + nonlocal total_size + + async with sem: + upload_part_response = await self.upload_part_copy(**part_args) + + finished_parts.append({'ETag': upload_part_response['CopyPartResult']['ETag'], 'PartNumber': part_args['PartNumber']}) + + # Call the callback, if it blocks then not good :/ + if Callback: + try: + total_size += size + Callback(total_size) + except: # noqa: E722 + pass + + num_parts = int(math.ceil(head_response['ContentLength'] / float(Config.multipart_chunksize))) + + tasks = [] + upload_kwargs = {k: v for k, v in ExtraArgs.items() if k in CopySubmissionTask.UPLOAD_PART_COPY_ARGS} + upload_kwargs.update({'Bucket': Bucket, 'Key': Key, 'CopySource': CopySource, 'UploadId': create_multipart_upload_resp['UploadId']}) + for part_number in range(1, num_parts + 1): + part_upload_kwargs = upload_kwargs.copy() + part_upload_kwargs['PartNumber'] = part_number + + range_start = (part_number - 1) * Config.multipart_chunksize + range_end = range_start + Config.multipart_chunksize - 1 + if part_number == num_parts: + range_end = head_response['ContentLength'] - 1 + + part_upload_kwargs['CopySourceRange'] = f'bytes={range_start}-{range_end}' + + tasks.append(uploader(range_end-range_start, part_upload_kwargs)) + + try: + await asyncio.gather(*tasks) + + assert len(finished_parts) == num_parts, "Number of finished upload parts does not match expected parts" + + finished_parts.sort(key=lambda item: item['PartNumber']) + + complete_upload_args = {k: v for k, v in ExtraArgs.items() if k in CopySubmissionTask.COMPLETE_MULTIPART_ARGS} + await self.complete_multipart_upload( + Bucket=Bucket, + Key=Key, + UploadId=create_multipart_upload_resp['UploadId'], + MultipartUpload={'Parts': finished_parts}, + **complete_upload_args + ) + + except Exception as err: + try: + await self.abort_multipart_upload(Bucket=Bucket, Key=Key, UploadId=create_multipart_upload_resp['UploadId']) + except Exception as err2: + raise err2 from err + raise err + + +async def bucket_load(self, *args, **kwargs): + """ + Calls s3.Client.list_buckets() to update the attributes of the Bucket + resource. + """ + # The docstring above is phrased this way to match what the autogenerated + # docs produce. + + # We can't actually get the bucket's attributes from a HeadBucket, + # so we need to use a ListBuckets and search for our bucket. + # However, we may fail if we lack permissions to ListBuckets + # or the bucket is in another account. In which case, creation_date + # will be None. + self.meta.data = {} + try: + response = await self.meta.client.list_buckets() + for bucket_data in response['Buckets']: + if bucket_data['Name'] == self.name: + self.meta.data = bucket_data + break + except ClientError as e: + if not e.response.get('Error', {}).get('Code') == 'AccessDenied': + raise diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5f8722ef1dc65282d285055de34d1bba207bd996 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_abnf.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_abnf.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8ec281937924fa25de8c9b3dfdc1e96bf006a66d Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_abnf.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_connection.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_connection.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..02025116c1eb85693a666032b29beda8a5b2ddeb Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_connection.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_events.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_events.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b9d5b667a527bf5fe6e434d05154782797add62d Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_events.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_headers.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_headers.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f1770f4b493b17f7462a41a12c36108da09bc083 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_headers.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_readers.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_readers.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb86789f5d012f13bf1710c1ff267a06ac8404f5 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_readers.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_receivebuffer.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_receivebuffer.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..760c6824feb219eb8bfca43d2eb49c87e32c23cd Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_receivebuffer.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_state.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_state.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb19316dad29d2f0c8cf02bf5708af3056843a58 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_state.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_util.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_util.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3de73269d608820c5f441c3b9ab75500be0707ca Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_util.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_version.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_version.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a66e715e917d65b443944d6ce7376bb673bc0684 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_version.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_writers.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_writers.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b6d8028bfbfe93e9fa671f8c98e651228083c424 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/h11/__pycache__/_writers.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/jiter/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/jiter/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2604cefb06b0414d09919ac215cb92fb874da010 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/jiter/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/llvmlite-0.47.0.dist-info/licenses/LICENSE b/data/conda_envs/evalclaw/lib/python3.11/site-packages/llvmlite-0.47.0.dist-info/licenses/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..8ac68163febf06e777f5d616414ef3021adb7fec --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/llvmlite-0.47.0.dist-info/licenses/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2014, Anaconda Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/llvmlite-0.47.0.dist-info/licenses/LICENSE.thirdparty b/data/conda_envs/evalclaw/lib/python3.11/site-packages/llvmlite-0.47.0.dist-info/licenses/LICENSE.thirdparty new file mode 100644 index 0000000000000000000000000000000000000000..d1ea17c2515d3bd7b1874da78aed51b1b8febbf8 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/llvmlite-0.47.0.dist-info/licenses/LICENSE.thirdparty @@ -0,0 +1,225 @@ +The llvmlite source tree includes code from LLVM that is governed by the +following license. + +============================================================================== +The Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..430b030a7ae4040cf3afde8ac6a6bcfc597ca8c2 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/harness.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/harness.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff91c552ab7bdf471dae2e502806fdded8645849 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/harness.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/ls.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/ls.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..722b5f9b398b2f1e9e55d2f526d25499df1d6152 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/ls.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/run.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/run.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..45400646255ad6d168ea550d7f9eb86a10ec2873 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/run.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/subcommand.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/subcommand.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a33bbec8e388bd2d66bc6891b55f5fd488997402 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/subcommand.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..192af6aed6afe0bea576b5a929fa93393271a73a Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/validate.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/validate.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..91bab1c085efbf91180c32dd4b7ef84949564792 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/_cli/__pycache__/validate.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf9ae994127d87b7c38cb73df452312f2e5e2747 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/anthropic_llms.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/anthropic_llms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..597e126b34ed9802f497ebd627100c02490b79eb Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/anthropic_llms.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/api_models.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/api_models.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d32515176e8b3c8ce2e45f7e52c7f4a52ca1549d Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/api_models.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/dummy.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/dummy.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4fa6c54a16ff7feeb7f368d91ea57b0a575da97c Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/dummy.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/gguf.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/gguf.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..160a0dbd2255320f40bb52b2df566c058ec0c398 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/gguf.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_audiolm.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_audiolm.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ce0d64c1a68e3a835b952a154cb2f78e2aa8641c Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_audiolm.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_steered.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_steered.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1cf1af41da4ebdc4b351fb510b6360dc3044c0f2 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_steered.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_vlms.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_vlms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4eba30bb61e647f4b0b9b1b5cef854405f34b8dc Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/hf_vlms.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/huggingface.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/huggingface.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5112ddbd30225daf03ae938ed8a23b8975f70d23 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/huggingface.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/ibm_watsonx_ai.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/ibm_watsonx_ai.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..81fe439ffa440c85330505bafd6bae61cfe26b30 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/ibm_watsonx_ai.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/litellm_llms.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/litellm_llms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..601c0b2b886f6d626757b7e59401631824ddddb5 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/litellm_llms.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/mamba_lm.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/mamba_lm.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..82a34ee2451b27b827db06cb5374def192020ebb Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/mamba_lm.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/megatron_lm.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/megatron_lm.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8087f95df5d7f625585abb63a135d3898aeb0ba1 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/megatron_lm.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/mistral3.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/mistral3.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..00d9787dcd37fb8e0e50fb8b3d9b5c77d93f7252 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/mistral3.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/nemo_lm.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/nemo_lm.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0bda590a152234e2e6524ef93a2d0734ef38b8ba Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/nemo_lm.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/neuron_optimum.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/neuron_optimum.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1de5cc561d9d924e74bef6930983c5ca6877d62d Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/neuron_optimum.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/openai_completions.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/openai_completions.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..19e767ce45b57021c659f6c479eabb4107d62f1a Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/openai_completions.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_habana.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_habana.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..13af0ddc45a66ba54994800a9623682444ecac27 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_habana.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_ipex.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_ipex.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..db034b1ee509deebfe176846dca14cf2042acb90 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_ipex.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_lm.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_lm.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..872620e7cd519637c6f5cfd5b04214b800ae9fa9 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/optimum_lm.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/sglang_causallms.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/sglang_causallms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c0cb8105d2c88768a29cceb0d6fb163bdcc5e2bc Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/sglang_causallms.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/sglang_generate_API.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/sglang_generate_API.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c217b7d66cb58e773913670ef20d04d448d5e9a7 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/sglang_generate_API.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/textsynth.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/textsynth.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..006ddde909b6e7593b0cffc447fa58ff12cdc4da Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/textsynth.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/trtllm_causallms.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/trtllm_causallms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..35c25fb804b504072c1e23e316312e6fe8334c88 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/trtllm_causallms.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..44ab1525528f5228dbbfeff4d16ec6406f6dae1e Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/utils_hf.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/utils_hf.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..be1d3b9191dd41761ac7c927c7c2ac94e2f83c2d Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/utils_hf.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/vllm_causallms.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/vllm_causallms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d1ad4c6cd4861eb9e6e3ef6960be12b6cb3a62b4 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/vllm_causallms.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/vllm_vlms.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/vllm_vlms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7a69abe8eea43cd36687bc1c47bde08da13b1eda Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/vllm_vlms.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/winml.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/winml.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6f698cd5deb9b5f612c18ec4d4867fe5b94ec355 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/models/__pycache__/winml.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/prompts/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/prompts/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..52dc2416f93f41cbb8c42bccb910a9f13a2680ea Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/prompts/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/aime/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/aime/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9acf34780d445efe3c07e4741006da6c8a96d7f Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/aime/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/chartqa/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/chartqa/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e917e80b5f118c19a4d1caf2bf06e8225b5b8975 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/chartqa/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/crows_pairs/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/crows_pairs/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..46162af07b47e1c5032c0bf6fbc21041107b1b92 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/crows_pairs/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/README.md b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d44078d2da27e9d34a22683caa0d2c6e66bf34e9 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/README.md @@ -0,0 +1,23 @@ +# MMLU Early Training + +This is a update of the MMLU benchmark (Hendrycks et al.) to evaluate models at early training stages. MMLU consists of multiple-choice questions from various branches of knowledge, such as humanities, social sciences, hard sciences. The dataset was created by selecting the 50% "easiest questions", that is, question in which there is a learning signal at the early training stages. Furthermore, MMLU is an multiple-choice dataset, and in this task, choices are not present in the prompt, and the target is the complete choice text, not only the choice letter. To further ensure signal at early training stages, the metric is defined as the difference of the log-likelihood of the correct choice and the average log-likelihood among incorrect choices. + +### Groups, Tags, and Tasks + +#### Groups +- Not part of a group yet. +#### Tasks +- `mmlu_early_training` + +### Checklist + +For adding novel benchmarks/datasets to the library: +* [ ] Is the task an existing benchmark in the literature? + * [ ] Have you referenced the original paper that introduced the task? + * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [ ] Is the "Main" variant of this task clearly denoted? +* [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/__pycache__/custom_metrics.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/__pycache__/custom_metrics.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..02710a202a892568b6a4205e75d996e82b3c39ba Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/__pycache__/custom_metrics.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/custom_metrics.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/custom_metrics.py new file mode 100644 index 0000000000000000000000000000000000000000..6608d2a8ad219f2f0c44a4f2f5afe9683da09ed6 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/custom_metrics.py @@ -0,0 +1,14 @@ +import numpy as np + + +def loglikelihood_diff(items): + diffs = [] + for item in items: + target, lls = item + target_ll = lls[target] + others_ll = [ll for i, ll in enumerate(lls) if i != target] + mean_others_ll = np.mean(others_ll) + diff = target_ll - mean_others_ll + diffs.append(diff) + + return np.mean(diffs) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/mmlu_early_training.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/mmlu_early_training.yaml new file mode 100644 index 0000000000000000000000000000000000000000..49571c391af05fa7d827147239555badcac75e4b --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/mmlu_early_training/mmlu_early_training.yaml @@ -0,0 +1,20 @@ +task: mmlu_early_training +dataset_path: giovanivaldrighi/mmlu +test_split: test +fewshot_split: dev +num_fewshot: 5 +fewshot_config: + sampler: first_n +output_type: multiple_choice +"description": "The following are multiple choice questions (with answers) about {{subject}}.\n\n" +doc_to_text: "Question: {{question.strip()}}\nAnswer:" +doc_to_choice: "{{choices}}" +doc_to_target: "{{answer}}" +metric_list: + - metric: likelihood + aggregation: !function custom_metrics.loglikelihood_diff + high_is_better: true +metadata: + version: 1.0 +dataset_kwargs: + trust_remote_code: true diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/README.md b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7a2dfe6a07a4fa027ea7dc87fc94b9aefa3b0aee --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/README.md @@ -0,0 +1,41 @@ +# Noor – MMLU-var Filtered Benchmark + +**Authors:** Mohammed Dahbani & Anas Ezzakri (IMT Atlantique) + +## Description + +This benchmark is a **filtered and improved version of MMLU/MMLU-var**, designed to provide a **stable, monotonic, and informative evaluation signal during the early stages of LLM training**. + +Standard MMLU often becomes noisy or non-discriminative for models that have seen only limited training. Our benchmark keeps only the questions that reliably reflect **true learning progress**. + +## Methodology + +### 1. Scientific Compliance Filtering +- Automatically retain all *hard-science* subjects (Math, Physics, Chemistry, etc.). +- For more variable subjects (Biology, Medicine, Humanities), apply an **LLM-as-a-Judge** process: + - Each question is evaluated **5 times**. + - A question is retained only if it receives **5/5 “Accept”** decisions. + +This ensures clarity, consistency, and the removal of ambiguous items. + +### 2. Signal Quality Filtering +For every question, we compute its **Confidence Margin** across all training checkpoints and fit a **linear regression**: + +- Only questions with a **positive slope** are retained. +- This ensures that each item produces a **smooth and monotonic learning trend**. + +The combination of both filters produces a benchmark that is cleaner, more stable, and much more sensitive to early-stage learning dynamics. + +## Task Structure + +The main group: +- `noor` + +This includes all subjects that pass both filtering stages. + +Each subject is also available as an independent task: +- Example: `noor_abstract_algebra`, `noor_college_physics`, `noor_machine_learning`, etc. + +## Purpose + +To provide a **reliable and low-noise evaluation signal** for early-stage LLMs, where traditional benchmarks usually fail to capture meaningful progress. diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/__pycache__/_generate_configs.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/__pycache__/_generate_configs.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e57f9f413bece6b49de05b7d6e96442157c8f4d3 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/__pycache__/_generate_configs.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_generate_configs.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_generate_configs.py new file mode 100644 index 0000000000000000000000000000000000000000..3d49275eadc9f2e57bbe8ecfb15486c7546e4442 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_generate_configs.py @@ -0,0 +1,159 @@ +# noqa +""" +Take in a YAML, and output all "other" splits with this YAML +""" + +import argparse +import logging +import os + +import yaml +from tqdm import tqdm + + +eval_logger = logging.getLogger("lm-eval") + + +SUBJECTS = { + "abstract_algebra": "stem", + "anatomy": "stem", + "astronomy": "stem", + "business_ethics": "other", + "clinical_knowledge": "other", + "college_biology": "stem", + "college_chemistry": "stem", + "college_computer_science": "stem", + "college_mathematics": "stem", + "college_medicine": "other", + "college_physics": "stem", + "computer_security": "stem", + "conceptual_physics": "stem", + "econometrics": "social_sciences", + "electrical_engineering": "stem", + "elementary_mathematics": "stem", + "formal_logic": "humanities", + # "global_facts": "other", + "high_school_biology": "stem", + "high_school_chemistry": "stem", + "high_school_computer_science": "stem", + "high_school_european_history": "humanities", + "high_school_geography": "social_sciences", + "high_school_government_and_politics": "social_sciences", + "high_school_macroeconomics": "social_sciences", + "high_school_mathematics": "stem", + "high_school_microeconomics": "social_sciences", + "high_school_physics": "stem", + "high_school_psychology": "social_sciences", + "high_school_statistics": "stem", + "high_school_us_history": "humanities", + "high_school_world_history": "humanities", + "human_aging": "other", + "human_sexuality": "social_sciences", + "international_law": "humanities", + "jurisprudence": "humanities", + "logical_fallacies": "humanities", + "machine_learning": "stem", + "management": "other", + "marketing": "other", + "medical_genetics": "other", + "miscellaneous": "other", + # "moral_disputes": "humanities", + # "moral_scenarios": "humanities", + "nutrition": "other", + "philosophy": "humanities", + "prehistory": "humanities", + "professional_accounting": "other", + # "professional_law": "humanities", + "professional_medicine": "other", + "professional_psychology": "social_sciences", + "public_relations": "social_sciences", + # "security_studies": "social_sciences", + "sociology": "social_sciences", + "us_foreign_policy": "social_sciences", + "virology": "other", + "world_religions": "humanities", +} + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--base_yaml_path", required=True) + parser.add_argument("--save_prefix_path", default="noor") + parser.add_argument("--cot_prompt_path", default=None) + parser.add_argument("--task_prefix", default="") + parser.add_argument("--group_prefix", default="") + return parser.parse_args() + + +if __name__ == "__main__": + args = parse_args() + + # get filename of base_yaml so we can `"include": ` it in our "other" YAMLs. + base_yaml_name = os.path.split(args.base_yaml_path)[-1] + with open(args.base_yaml_path, encoding="utf-8") as f: + base_yaml = yaml.full_load(f) + + if args.cot_prompt_path is not None: + import json + + with open(args.cot_prompt_path, encoding="utf-8") as f: + cot_file = json.load(f) + + ALL_CATEGORIES = [] + for subject, category in tqdm(SUBJECTS.items()): + if category not in ALL_CATEGORIES: + ALL_CATEGORIES.append(category) + + if args.cot_prompt_path is not None: + description = cot_file[subject] + else: + description = f"The following are multiple choice questions (with answers) about {' '.join(subject.split('_'))}.\n\n" + + yaml_dict = { + "include": base_yaml_name, + "tag": f"noor_{args.task_prefix}_{category}" + if args.task_prefix != "" + else f"noor_{category}", + "task": f"noor_{args.task_prefix}_{subject}" + if args.task_prefix != "" + else f"noor_{subject}", + "task_alias": subject.replace("_", " "), + "dataset_name": subject, + "description": description, + } + + file_save_path = args.save_prefix_path + f"_{subject}.yaml" + eval_logger.info(f"Saving yaml for subset {subject} to {file_save_path}") + with open(file_save_path, "w", encoding="utf-8") as yaml_file: + yaml.dump( + yaml_dict, + yaml_file, + allow_unicode=True, + default_style='"', + ) + + if args.task_prefix != "": + noor_subcategories = [ + f"noor_{args.task_prefix}_{category}" for category in ALL_CATEGORIES + ] + else: + noor_subcategories = [f"noor_{category}" for category in ALL_CATEGORIES] + + if args.group_prefix != "": + file_save_path = args.group_prefix + ".yaml" + else: + file_save_path = args.save_prefix_path + ".yaml" + + eval_logger.info(f"Saving benchmark config to {file_save_path}") + with open(file_save_path, "w", encoding="utf-8") as yaml_file: + yaml.dump( + { + "group": f"noor_{args.task_prefix}" + if args.task_prefix != "" + else "noor", + "task": noor_subcategories, + }, + yaml_file, + indent=4, + default_flow_style=False, + ) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bc5fe166b40819a82b4e9719e523692b376357de --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor.yaml @@ -0,0 +1,14 @@ +group: noor +group_alias: noor +task: + - group: stem + task: + - noor_stem + aggregate_metric_list: + - metric: acc + weight_by_size: True +aggregate_metric_list: + - metric: acc + weight_by_size: True +metadata: + version: 2 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor_stem.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor_stem.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1890ef0f9e253c5d683ffbf3330334fcbc6d48d7 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor_stem.yaml @@ -0,0 +1,9 @@ +group: noor_stem +group_alias: stem +task: + - noor_stem_tasks +aggregate_metric_list: + - metric: acc + weight_by_size: True +metadata: + version: 2 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor_template b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor_template new file mode 100644 index 0000000000000000000000000000000000000000..fefcebdb1acce22b7303f2a4fd1ddb5472b6b151 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/_noor_template @@ -0,0 +1,20 @@ +# task: noor +dataset_path: mdahba/noor_final2 +output_type: multiple_choice # or: generate_until, loglikelihood, loglikelihood_rolling +# training_split: train +validation_split: validation +test_split: test +fewshot_split: dev +num_fewshot: 5 +fewshot_config: + sampler: first_n +doc_to_text: "Question: {{question.strip()}}\nAnswer:" +doc_to_choice: "{{choices}}" +doc_to_target: "{{answer}}" +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true + - metric: acc_norm + aggregation: mean + higher_is_better: true diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_abstract_algebra.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_abstract_algebra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..61ad3c8ea6b64f2b8f924b8b4e00f0a24e0c27b4 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_abstract_algebra.yaml @@ -0,0 +1,7 @@ +"dataset_name": "abstract_algebra" +"description": "The following are multiple choice questions (with answers) about abstract\ + \ algebra.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_abstract_algebra" +"task_alias": "abstract algebra" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_computer_science.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_computer_science.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6eba00e1227465f872df0b3ebe3ab92da037773e --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_computer_science.yaml @@ -0,0 +1,7 @@ +"dataset_name": "college_computer_science" +"description": "The following are multiple choice questions (with answers) about college\ + \ computer science.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_college_computer_science" +"task_alias": "college computer science" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_mathematics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_mathematics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9d6b46dde9c21779d3af5a9070a0709bc9c0c24b --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_mathematics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "college_mathematics" +"description": "The following are multiple choice questions (with answers) about college\ + \ mathematics.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_college_mathematics" +"task_alias": "college mathematics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_physics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1a391923a2fdff003fe6a0e9f5372e10ac9db579 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_college_physics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "college_physics" +"description": "The following are multiple choice questions (with answers) about college\ + \ physics.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_college_physics" +"task_alias": "college physics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_conceptual_physics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_conceptual_physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a5c4bc6fd9b16acf303b6ff95e89ec94bcedd741 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_conceptual_physics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "conceptual_physics" +"description": "The following are multiple choice questions (with answers) about conceptual\ + \ physics.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_conceptual_physics" +"task_alias": "conceptual physics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_electrical_engineering.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_electrical_engineering.yaml new file mode 100644 index 0000000000000000000000000000000000000000..641b71964bdcce1f93417a16f0028948e1642b2a --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_electrical_engineering.yaml @@ -0,0 +1,7 @@ +"dataset_name": "electrical_engineering" +"description": "The following are multiple choice questions (with answers) about electrical\ + \ engineering.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_electrical_engineering" +"task_alias": "electrical engineering" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_elementary_mathematics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_elementary_mathematics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fe758acac3d2c7b42aec1c9ed6ecd2ce8403a35b --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_elementary_mathematics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "elementary_mathematics" +"description": "The following are multiple choice questions (with answers) about elementary\ + \ mathematics.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_elementary_mathematics" +"task_alias": "elementary mathematics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_computer_science.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_computer_science.yaml new file mode 100644 index 0000000000000000000000000000000000000000..382f867dd41be76f00995fc593e7b5b530340291 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_computer_science.yaml @@ -0,0 +1,7 @@ +"dataset_name": "high_school_computer_science" +"description": "The following are multiple choice questions (with answers) about high\ + \ school computer science.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_high_school_computer_science" +"task_alias": "high school computer science" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_mathematics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_mathematics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..31030477abe334f8daac9fa452def4ee5f17741c --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_mathematics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "high_school_mathematics" +"description": "The following are multiple choice questions (with answers) about high\ + \ school mathematics.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_high_school_mathematics" +"task_alias": "high school mathematics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_physics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..46c92f9576659e0978fe2ad2567cbc021f58067d --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_physics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "high_school_physics" +"description": "The following are multiple choice questions (with answers) about high\ + \ school physics.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_high_school_physics" +"task_alias": "high school physics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_statistics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_statistics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..55b9bbe8314f51b8b9979c412f250803fc2a283d --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_high_school_statistics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "high_school_statistics" +"description": "The following are multiple choice questions (with answers) about high\ + \ school statistics.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_high_school_statistics" +"task_alias": "high school statistics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_machine_learning.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_machine_learning.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b9fc7d57a66b95142aa3a3de5ea34c831539a0e3 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/noor/noor_machine_learning.yaml @@ -0,0 +1,7 @@ +"dataset_name": "machine_learning" +"description": "The following are multiple choice questions (with answers) about machine\ + \ learning.\n\n" +"include": "_noor_template" +"tag": "noor_stem_tasks" +"task": "noor_machine_learning" +"task_alias": "machine learning" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/README.md b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/README.md new file mode 100644 index 0000000000000000000000000000000000000000..98b1db5595d8c40f39cbbb0ec7e6d85c610909d5 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/README.md @@ -0,0 +1,47 @@ +# SciKnowEval_mcqa + +This task was submitted at the [NeurIPS 2025 E2LM](https://e2lmc.github.io/) competition, and reached $3^{rd}$ place on the general leaderboard. +Its intended use is within the context of Small Language Model (SLM) evaluation in early training stages. More details are provided in the competition [proposal paper](https://arxiv.org/pdf/2506.07731). + +### Benchmark details + +This task uses a subset of the [SciKnowEval](https://huggingface.co/datasets/hicai-zju/SciKnowEval) dataset. Specifically, it filters out non-MCQA samples and focuses on questions from levels L1, L2, and L3, which are designed to assess knowledge memory, comprehension and reasoning respectively, as described in the original [paper](https://arxiv.org/pdf/2406.09098v2). + +The full SciKnowEval dataset is a comprehensive benchmark for evaluating the scientific knowledge reasoning capabilities of Large Language Models (LLMs). It spans across a few scientific domains: Physics, Chemistry, Biology and Materials. + +SciKnowEval_mcqa dataset: https://huggingface.co/datasets/ShAIkespear/SciKnowEval_mcqa + +### Citation + +``` +@misc{sci-know-2025-mcqa, + title = "SciKnowEval_mcqa: A Benchmark for Small Language Model Evaluation in their Early Training Stages", + author = "Anthony Kalaydjian, Eric Saikali", + year = "2025", +} +``` + +### Groups and Tasks + +#### Groups + +* `sciknoweval_mcqa`: Evaluates `sciknoweval_Biology`, `sciknoweval_Chemistry`, `sciknoweval_Materials` and `sciknoweval_Physics` + +#### Tasks +* `sciknoweval_Biology`: Data across all remaining splits corresponding to Biology MCQs. +* `sciknoweval_Chemistry`: Data across all remaining splits corresponding to Chemistry MCQs. +* `sciknoweval_Materials`: Data across all remaining splits corresponding to Materials MCQs. +* `sciknoweval_Physics`: Data across all remaining splits corresponding to Physics MCQs. + +### Checklist + +For adding novel benchmarks/datasets to the library: + * [ ] Is the task an existing benchmark in the literature? + * [x] Have you referenced the original paper that introduced the task? + * [x] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [x] Is the "Main" variant of this task clearly denoted? +* [x] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/_sciknoweval_mcqa.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/_sciknoweval_mcqa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..41ca3bddf37cb99fe289faa1d517ab85d672d537 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/_sciknoweval_mcqa.yaml @@ -0,0 +1,9 @@ +group: sciknoweval_mcqa +group_alias: sciknoweval_mcqa (var5shots) +task: + - sciknoweval_mcqa_task +aggregate_metric_list: + - metric: acc + weight_by_size: True +metadata: + version: 2 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/_var5shots_template_yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/_var5shots_template_yaml new file mode 100644 index 0000000000000000000000000000000000000000..547c04314180d984396f481d0503601645ac2981 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/_var5shots_template_yaml @@ -0,0 +1,14 @@ +dataset_path: ShAIkespear/SciKnowEval_mcqa +output_type: multiple_choice +test_split: test +fewshot_split: dev +num_fewshot: 5 +fewshot_config: + sampler: first_n +doc_to_text: "Question: {{question.strip()}}\nAnswer:" +doc_to_choice: "{{choices}}" +doc_to_target: "{{answer}}" +metadata: + version: 1.0 +dataset_kwargs: + trust_remote_code: true diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Biology.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Biology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e83f0bc5a537b328bc8b23b94dc87eeace11733b --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Biology.yaml @@ -0,0 +1,7 @@ +"dataset_name": "Biology" +"description": "The following are multiple choice questions (with answers) about Biology.\n\ + \n" +"include": "_var5shots_template_yaml" +"tag": "sciknoweval_mcqa_task" +"task": "sciknoweval_mcqa_var5shots_Biology" +"task_alias": "Biology" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Chemistry.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Chemistry.yaml new file mode 100644 index 0000000000000000000000000000000000000000..be187bc8b73c58c8de6657850cd4dacad2f75e03 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Chemistry.yaml @@ -0,0 +1,7 @@ +"dataset_name": "Chemistry" +"description": "The following are multiple choice questions (with answers) about Chemistry.\n\ + \n" +"include": "_var5shots_template_yaml" +"tag": "sciknoweval_mcqa_task" +"task": "sciknoweval_mcqa_var5shots_Chemistry" +"task_alias": "Chemistry" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Material.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Material.yaml new file mode 100644 index 0000000000000000000000000000000000000000..21856989a004987e3ae5da42da28252087d85ef2 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Material.yaml @@ -0,0 +1,7 @@ +"dataset_name": "Material" +"description": "The following are multiple choice questions (with answers) about Material.\n\ + \n" +"include": "_var5shots_template_yaml" +"tag": "sciknoweval_mcqa_task" +"task": "sciknoweval_mcqa_var5shots_Material" +"task_alias": "Material" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Physics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4d58d6f5752c7e3603077ee77a49eaa50119a4e6 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/e2lmc/sciknoweval_mcqa/sciknoweval_Physics.yaml @@ -0,0 +1,7 @@ +"dataset_name": "Physics" +"description": "The following are multiple choice questions (with answers) about Physics.\n\ + \n" +"include": "_var5shots_template_yaml" +"tag": "sciknoweval_mcqa_task" +"task": "sciknoweval_mcqa_var5shots_Physics" +"task_alias": "Physics" diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/eus_reading/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/eus_reading/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3e9e9df4ee4560ba3ebcc42155eae26d372f8223 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/eus_reading/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1dcc23ab5a8e97c057c968095cdf9db9f743e063 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/__pycache__/create_yamls_flores_gl.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/__pycache__/create_yamls_flores_gl.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..239b2cd26e7729ab06de3c3d059cf0dcb71e3821 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/__pycache__/create_yamls_flores_gl.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/_flores_common_yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/_flores_common_yaml new file mode 100644 index 0000000000000000000000000000000000000000..e488d5cb3f6e19ec9824cbe3fd3295450bfad885 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/_flores_common_yaml @@ -0,0 +1,25 @@ +dataset_path: facebook/flores +dataset_name: all +output_type: generate_until +#! The test split of flores is not publicly available! (See paper section 6.1) +#! We are using `dev` and `devtest` splits, but they're mapped to train/validation/test in `data/flores/flores.py`. +training_split: dev +validation_split: dev +test_split: devtest +fewshot_split: dev +target_delimiter: '' +generation_kwargs: + until: + - "\n" +metric_list: + - metric: bleu + aggregation: bleu + higher_is_better: true + - metric: ter + aggregation: ter + higher_is_better: false + - metric: chrf + aggregation: chrf + higher_is_better: true +metadata: + version: 1.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/create_yamls_flores_gl.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/create_yamls_flores_gl.py new file mode 100644 index 0000000000000000000000000000000000000000..3569652da136700a3e2e925a8d6cada100a39a58 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/create_yamls_flores_gl.py @@ -0,0 +1,333 @@ +# ruff: noqa: E731, E741 +""" +Script to generate task YAMLs for the FLORES-200 dataset. +Based on `tasks/translation/utils.py`. +""" + +import argparse +import itertools + +import yaml +from langcodes import Language + + +# utils +flatten = lambda l: list(itertools.chain(*l)) + +# constants +_LANGUAGES = [ + "ace_Arab", + "bam_Latn", + "dzo_Tibt", + "hin_Deva", + "khm_Khmr", + "mag_Deva", + "pap_Latn", + "sot_Latn", + "tur_Latn", + "ace_Latn", + "ban_Latn", + "ell_Grek", + "hne_Deva", + "kik_Latn", + "mai_Deva", + "pbt_Arab", + "spa_Latn", + "twi_Latn", + "acm_Arab", + "bel_Cyrl", + "eng_Latn", + "hrv_Latn", + "kin_Latn", + "mal_Mlym", + "pes_Arab", + "srd_Latn", + "tzm_Tfng", + "acq_Arab", + "bem_Latn", + "epo_Latn", + "hun_Latn", + "kir_Cyrl", + "mar_Deva", + "plt_Latn", + "srp_Cyrl", + "uig_Arab", + "aeb_Arab", + "ben_Beng", + "est_Latn", + "hye_Armn", + "kmb_Latn", + "min_Arab", + "pol_Latn", + "ssw_Latn", + "ukr_Cyrl", + "afr_Latn", + "bho_Deva", + "eus_Latn", + "ibo_Latn", + "kmr_Latn", + "min_Latn", + "por_Latn", + "sun_Latn", + "umb_Latn", + "ajp_Arab", + "bjn_Arab", + "ewe_Latn", + "ilo_Latn", + "knc_Arab", + "mkd_Cyrl", + "prs_Arab", + "swe_Latn", + "urd_Arab", + "aka_Latn", + "bjn_Latn", + "fao_Latn", + "ind_Latn", + "knc_Latn", + "mlt_Latn", + "quy_Latn", + "swh_Latn", + "uzn_Latn", + "als_Latn", + "bod_Tibt", + "fij_Latn", + "isl_Latn", + "kon_Latn", + "mni_Beng", + "ron_Latn", + "szl_Latn", + "vec_Latn", + "amh_Ethi", + "bos_Latn", + "fin_Latn", + "ita_Latn", + "kor_Hang", + "mos_Latn", + "run_Latn", + "tam_Taml", + "vie_Latn", + "apc_Arab", + "bug_Latn", + "fon_Latn", + "jav_Latn", + "lao_Laoo", + "mri_Latn", + "rus_Cyrl", + "taq_Latn", + "war_Latn", + "arb_Arab", + "bul_Cyrl", + "fra_Latn", + "jpn_Jpan", + "lij_Latn", + "mya_Mymr", + "sag_Latn", + "taq_Tfng", + "wol_Latn", + "arb_Latn", + "cat_Latn", + "fur_Latn", + "kab_Latn", + "lim_Latn", + "nld_Latn", + "san_Deva", + "tat_Cyrl", + "xho_Latn", + "ars_Arab", + "ceb_Latn", + "fuv_Latn", + "kac_Latn", + "lin_Latn", + "nno_Latn", + "sat_Olck", + "tel_Telu", + "ydd_Hebr", + "ary_Arab", + "ces_Latn", + "gaz_Latn", + "kam_Latn", + "lit_Latn", + "nob_Latn", + "scn_Latn", + "tgk_Cyrl", + "yor_Latn", + "arz_Arab", + "cjk_Latn", + "gla_Latn", + "kan_Knda", + "lmo_Latn", + "npi_Deva", + "shn_Mymr", + "tgl_Latn", + "yue_Hant", + "asm_Beng", + "ckb_Arab", + "gle_Latn", + "kas_Arab", + "ltg_Latn", + "nso_Latn", + "sin_Sinh", + "tha_Thai", + "zho_Hans", + "ast_Latn", + "crh_Latn", + "glg_Latn", + "kas_Deva", + "ltz_Latn", + "nus_Latn", + "slk_Latn", + "tir_Ethi", + "zho_Hant", + "awa_Deva", + "cym_Latn", + "grn_Latn", + "kat_Geor", + "lua_Latn", + "nya_Latn", + "slv_Latn", + "tpi_Latn", + "zsm_Latn", + "ayr_Latn", + "dan_Latn", + "guj_Gujr", + "kaz_Cyrl", + "lug_Latn", + "oci_Latn", + "smo_Latn", + "tsn_Latn", + "zul_Latn", + "azb_Arab", + "deu_Latn", + "hat_Latn", + "kbp_Latn", + "luo_Latn", + "ory_Orya", + "sna_Latn", + "tso_Latn", + "azj_Latn", + "dik_Latn", + "hau_Latn", + "kea_Latn", + "lus_Latn", + "pag_Latn", + "snd_Arab", + "tuk_Latn", + "bak_Cyrl", + "dyu_Latn", + "heb_Hebr", + "khk_Cyrl", + "lvs_Latn", + "pan_Guru", + "som_Latn", + "tum_Latn", +] +LANGUAGE_PAIRS = [ + (a, b) for idx, a in enumerate(_LANGUAGES) for b in _LANGUAGES[idx + 1 :] +] + +LANGUAGES_OF_INTEREST = [ + "cat_Latn", + "spa_Latn", + "eng_Latn", + "glg_Latn", + "eus_Latn", + "ita_Latn", + "deu_Latn", + "por_Latn", + "fra_Latn", +] +MAIN_LANG = "glg_Latn" +LANGUAGE_PAIRS = [ + (a, b) + for (a, b) in LANGUAGE_PAIRS + if a in LANGUAGES_OF_INTEREST and b in LANGUAGES_OF_INTEREST and MAIN_LANG in (a, b) +] + +# auxiliary functions + +code_to_language_name = lambda code: Language.make( + language=Language.get(code)["language"] +).display_name() +code_to_short_name = lambda code: Language.get(code)["language"] +jinja_var = ( + lambda s: "{{" + s + "}}" +) # wrapper to avoid having to escape { } in format strings + + +def doc_to_text(src: str, tgt: str) -> str: + src_name, tgt_name = map(code_to_language_name, [src, tgt]) + + return f"""\ +{src_name} sentence: {jinja_var("sentence_" + src)} +{tgt_name} sentence:""" + + +def doc_to_target(tgt: str) -> str: + return f"{jinja_var('sentence_' + tgt)}" + + +# main function + + +def gen_lang_yamls(output_dir: str, overwrite: bool) -> None: + """ + Generate a YAML file for each translation direction. + """ + + err = [] + for src, tgt in LANGUAGE_PAIRS: + # do both translation directions for each lang pair + for src, tgt in [(src, tgt), (tgt, src)]: + lang_pair_name = f"{code_to_short_name(src)}-{code_to_short_name(tgt)}" + yaml_file_name = f"flores_{lang_pair_name}.yaml" + + try: + with open( + f"{output_dir}/{yaml_file_name}", + "w" if overwrite else "x", + encoding="utf-8", + ) as outfile: + print(f"Creating {yaml_file_name}...") + outfile.write("# File generated by `create-yamls.py`\n") + yaml.dump( + { + # "group": [f"{BENCH_NAME}_bench", f"{BENCH_NAME}_bench_flores"], + # "group": "flores_gl", + "include": "_flores_common_yaml", + "task": f"galician_bench_flores_{lang_pair_name}", + "doc_to_text": doc_to_text(src, tgt), + "doc_to_target": doc_to_target(tgt), + }, + outfile, + sort_keys=False, + ) + + except FileExistsError: + err.append(yaml_file_name) + + if len(err) > 0: + raise FileExistsError( + "Files were not created because they already exist:" + f" {', '.join(err)}" + "\nUse flag --overwrite to overwrite them." + ) + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument( + "--overwrite", + default=False, + action="store_true", + help="Overwrite files if they already exist", + ) + parser.add_argument( + "--output-dir", default=".", help="Directory to write yaml files to" + ) + args = parser.parse_args() + + gen_lang_yamls(output_dir=args.output_dir, overwrite=args.overwrite) + + +if __name__ == "__main__": + main() diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_ca-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_ca-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c0c1061bda08d86310f8e93423fbfcbb7dbe01cc --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_ca-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_ca-gl +doc_to_text: 'Catalan sentence: {{sentence_cat_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_de-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_de-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3e72695e083b5abccba7357aa6dda3cb4903928b --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_de-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_de-gl +doc_to_text: 'German sentence: {{sentence_deu_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_en-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_en-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..56b9dd9a6fbd81927ad23333ed020dbcdaa10315 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_en-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_en-gl +doc_to_text: 'English sentence: {{sentence_eng_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_es-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_es-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..181c765f2144a32b0e53aff6ae2a8dbf973c1e82 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_es-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_es-gl +doc_to_text: 'Spanish sentence: {{sentence_spa_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_eu-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_eu-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d8179f741f7e554606cfbeff581e83cf998f7068 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_eu-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_eu-gl +doc_to_text: 'Basque sentence: {{sentence_eus_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_fr-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_fr-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..211ce0fd693d01c52f41d2c18cf40b13477c9d30 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_fr-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_fr-gl +doc_to_text: 'French sentence: {{sentence_fra_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-ca.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-ca.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f1ce69d52d8426575550cc522d78c158dffde40a --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-ca.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-ca +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + Catalan sentence:' +doc_to_target: '{{sentence_cat_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-de.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-de.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cb8eb774deba439564b41d217b920388877ba8a0 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-de.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-de +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + German sentence:' +doc_to_target: '{{sentence_deu_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-en.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-en.yaml new file mode 100644 index 0000000000000000000000000000000000000000..48a640af280081a115a025e530729d8f6e68cbd5 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-en.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-en +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + English sentence:' +doc_to_target: '{{sentence_eng_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-es.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-es.yaml new file mode 100644 index 0000000000000000000000000000000000000000..afe19f00bc873f7c37448bf17c122f053767dfb0 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-es.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-es +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + Spanish sentence:' +doc_to_target: '{{sentence_spa_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-eu.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-eu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5954c1c71ac1f4767a5ecaf7826b3094bcf47703 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-eu.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-eu +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + Basque sentence:' +doc_to_target: '{{sentence_eus_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-fr.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-fr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..33d0de20781025b08a1ec3c5d281873ea224f71d --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-fr.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-fr +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + French sentence:' +doc_to_target: '{{sentence_fra_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-it.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-it.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b9890f65c12cd0578f45bb80f8ec4ae0380a5ab --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-it.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-it +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + Italian sentence:' +doc_to_target: '{{sentence_ita_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-pt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-pt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..70ff6fa90e8d77a371453ffca7965e117092e3ff --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl-pt.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_gl-pt +doc_to_text: 'Galician sentence: {{sentence_glg_Latn}} + + Portuguese sentence:' +doc_to_target: '{{sentence_por_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9bd9c6987dc21a483a1837b19e2caba8e95b993c --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_gl.yaml @@ -0,0 +1,24 @@ +group: flores_gl +task: + - galician_bench_flores_es-gl + - galician_bench_flores_gl-es + - galician_bench_flores_en-gl + - galician_bench_flores_gl-en + - galician_bench_flores_eu-gl + - galician_bench_flores_gl-eu + - galician_bench_flores_pt-gl + - galician_bench_flores_gl-pt + - galician_bench_flores_it-gl + - galician_bench_flores_gl-it + - galician_bench_flores_fr-gl + - galician_bench_flores_gl-fr + - galician_bench_flores_ca-gl + - galician_bench_flores_gl-ca + - galician_bench_flores_gl-de + - galician_bench_flores_de-gl +aggregate_metric_list: + - metric: bleu + aggregation: mean + weight_by_size: false +metadata: + version: 1.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_it-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_it-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..04d56c8a657b21ab81bbef4c9b621318845f3b3b --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_it-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_it-gl +doc_to_text: 'Italian sentence: {{sentence_ita_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_pt-gl.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_pt-gl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..61a89da201db8444e30e982b0f72304cfec7ec13 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/galician_bench/flores_gl/flores_pt-gl.yaml @@ -0,0 +1,7 @@ +# File generated by `create-yamls.py` +include: _flores_common_yaml +task: galician_bench_flores_pt-gl +doc_to_text: 'Portuguese sentence: {{sentence_por_Latn}} + + Galician sentence:' +doc_to_target: '{{sentence_glg_Latn}}' diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/glianorex/__pycache__/preprocess_glianorex.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/glianorex/__pycache__/preprocess_glianorex.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e4284df157c79edde94ac1f659168750b6ee68e9 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/glianorex/__pycache__/preprocess_glianorex.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/groundcocoa/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/groundcocoa/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b90c0b2025be45e36122b2cf826bde4e1621374c Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/groundcocoa/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/hellaswag/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/hellaswag/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6c8ee3d5ba30dd9b521db9859ceb40d95ba898c8 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/hellaswag/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/metabench/__pycache__/process_docs.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/metabench/__pycache__/process_docs.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d479657e2cdcd700c4e83f75b21339a2e2b88dcc Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/metabench/__pycache__/process_docs.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/metabench/__pycache__/process_docs_permute.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/metabench/__pycache__/process_docs_permute.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9ce82203862b8309a6f0e0ca6cbc5ba38daebcf2 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/metabench/__pycache__/process_docs_permute.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mimic_repsum/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mimic_repsum/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0492410f5920002f4410e6424fdc857ede2223a3 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mimic_repsum/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mimic_repsum/__pycache__/utils_perplexity.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mimic_repsum/__pycache__/utils_perplexity.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f30ef4ad012d0c240213e3386c00426a93570746 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mimic_repsum/__pycache__/utils_perplexity.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/minerva_math/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/minerva_math/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2889eb2343890300f54d3d7975378835cfb4fa0e Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/minerva_math/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mmmu/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mmmu/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f86d11ce11fddaf01846ff658b6da5331840ea44 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/mmmu/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/olaph/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/olaph/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6cc406b326e0558118c373a1a33ad175cbc16f3e Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/olaph/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/olaph/__pycache__/utils_perplexity.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/olaph/__pycache__/utils_perplexity.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2e2290855ca87352d2d0cb0037aa146b30dafd41 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/olaph/__pycache__/utils_perplexity.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/qasper/__pycache__/metrics.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/qasper/__pycache__/metrics.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5f51b5999022f2d8d1f7beae1a688189659debe8 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/qasper/__pycache__/metrics.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/qasper/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/qasper/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b465cacf509c08e2ace2391377afa6cdacb9904d Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/qasper/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/scrolls/__pycache__/task.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/scrolls/__pycache__/task.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4481aa9578598d97da438444f5aeac48a21ef5ad Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/scrolls/__pycache__/task.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/simple_cooccurrence_bias/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/simple_cooccurrence_bias/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..55ea2a1bda913ed2c5c30843f4acce98ddde18b6 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/simple_cooccurrence_bias/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/squadv2/__pycache__/task.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/squadv2/__pycache__/task.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..069862d055a853bbb784623f493d86bb400b6ad1 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/squadv2/__pycache__/task.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0eaec518da5a30f70896770b1bc41739c6e1fc69 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/default.yaml @@ -0,0 +1,17 @@ +tag: + - super-glue-lm-eval-v1 +task: boolq +dataset_path: aps/super_glue +dataset_name: boolq +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: "{{passage}}\nQuestion: {{question}}?\nAnswer:" +doc_to_target: label +doc_to_choice: ["no", "yes"] +should_decontaminate: true +doc_to_decontamination_query: passage +metric_list: + - metric: acc +metadata: + version: 2.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/seq2seq.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/seq2seq.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9b20c022f24eac8486866cb41967f44618e29c2c --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/seq2seq.yaml @@ -0,0 +1,26 @@ +tag: + - super-glue-lm-eval-v1-seq2seq +task: "boolq-seq2seq" +dataset_path: aps/super_glue +dataset_name: boolq +output_type: generate_until +training_split: train +validation_split: validation +doc_to_text: "{{passage}}\nQuestion: {{question}}?\nAnswer:" +doc_to_target: label +doc_to_choice: [' no', ' yes'] +target_delimiter: "" +generation_kwargs: + until: + - "\n\n" + - "\n" + do_sample: false + temperature: 0.0 +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c705dbe6e0edd750559105a45c35a63596815fb1 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/boolq/t5-prompt.yaml @@ -0,0 +1,22 @@ +tag: + - super-glue-t5-prompt +task: super_glue-boolq-t5-prompt +dataset_path: aps/super_glue +dataset_name: boolq +training_split: train +validation_split: validation +output_type: generate_until +doc_to_text: "boolq passage: {{passage}} question: {{question}}" +doc_to_target: label +doc_to_choice: ['False', 'True'] +generation_kwargs: + until: + - "" +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/__pycache__/aggregate.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/__pycache__/aggregate.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e3fb4dea3433d8afc8baf8ad5368cf91c79f48b4 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/__pycache__/aggregate.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/__pycache__/t5_utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/__pycache__/t5_utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d2aff23bd7528cc0ec44743e1bde79dd5f492d93 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/__pycache__/t5_utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/aggregate.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..d8c1af3580eea906fed64990a317e9cd7766db15 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/aggregate.py @@ -0,0 +1,14 @@ +import numpy as np + + +def cb_multi_fi(items): + from sklearn.metrics import f1_score + + preds, golds = zip(*items) + preds = np.array(preds) + golds = np.array(golds) + f11 = f1_score(y_true=golds == 0, y_pred=preds == 0) + f12 = f1_score(y_true=golds == 1, y_pred=preds == 1) + f13 = f1_score(y_true=golds == 2, y_pred=preds == 2) + avg_f1 = np.mean([f11, f12, f13]) + return avg_f1 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..61177bc244e2488a5c431db46dde09bfdb33639d --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/default.yaml @@ -0,0 +1,17 @@ +tag: + - super-glue-lm-eval-v1 +task: cb +dataset_path: aps/super_glue +dataset_name: cb +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: "{{premise}}\nQuestion: {{hypothesis}}. True, False, or Neither?\nAnswer:" +doc_to_target: label +doc_to_choice: ['True', 'False', 'Neither'] +metric_list: + - metric: acc + - metric: f1 + aggregation: !function "aggregate.cb_multi_fi" +metadata: + version: 1.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8ae2eb06b10e31ea9304e67720ecf32a5610822a --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/t5-prompt.yaml @@ -0,0 +1,25 @@ +tag: + - super-glue-t5-prompt +task: super_glue-cb-t5-prompt +dataset_path: aps/super_glue +dataset_name: cb +training_split: train +validation_split: validation +output_type: generate_until +doc_to_text: "cb hypothesis: {{hypothesis}} premise: {{premise}}" +doc_to_target: label +doc_to_choice: ['entailment', 'contradiction', 'neutral'] +generation_kwargs: + until: + - "" +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + - metric: !function "t5_utils.mean_3class_f1" + aggregation: !function "t5_utils.agg_mean_3class_f1" + higher_is_better: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/t5_utils.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/t5_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..33cbaddf43988a4b7253a647b59885bf91437a23 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/cb/t5_utils.py @@ -0,0 +1,29 @@ +def mean_3class_f1(predictions, references): # This is a passthrough function + string_label = ["entailment", "contradiction", "neutral"] + predictions = ( + string_label.index(predictions[0]) if predictions[0] in string_label else 0 + ) + references = string_label.index(references[0]) + + return (predictions, references) + + +def agg_mean_3class_f1(items): + predictions, references = zip(*items) + + """Computes the unweighted average of the F1 per class.""" + metric_str = "fbeta_score" + metric_fn_kwargs = { + "beta": 1, + "labels": range(3), + "average": "macro", + } + + def _fn(predictions, references): + import sklearn.metrics + + metric_fn = getattr(sklearn.metrics, metric_str) + metric_val = metric_fn(references, predictions, **metric_fn_kwargs) + return metric_val + + return _fn(predictions, references) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..59b3addb26ea3424c47edb6a315424ffcd427f34 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fff4312ac8871ec2efafbd0abf17087657ad6b8a --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/default.yaml @@ -0,0 +1,15 @@ +tag: + - super-glue-lm-eval-v1 +task: copa +dataset_path: aps/super_glue +dataset_name: copa +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: !function utils.doc_to_text +doc_to_target: !function utils.doc_to_target +doc_to_choice: !function utils.doc_to_choice +metric_list: + - metric: acc +metadata: + version: 1.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4c64c367c8b595bd94fbfd25909aeb2cc8fa58a4 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/t5-prompt.yaml @@ -0,0 +1,22 @@ +tag: + - super-glue-t5-prompt +task: super_glue-copa-t5-prompt +dataset_path: aps/super_glue +dataset_name: copa +training_split: train +validation_split: validation +output_type: generate_until +doc_to_text: "copa choice1: {{choice1}} choice2: {{choice2}} premise: {{premise}} question: {{question}}" +doc_to_target: label +doc_to_choice: ['choice1', 'choice2'] +generation_kwargs: + until: + - "" +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/utils.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3afc868eb486c47c51b0036ce955502bc377c9c4 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/copa/utils.py @@ -0,0 +1,21 @@ +def convert_choice(choice): + return choice[0].lower() + choice[1:] + + +def doc_to_text(doc): + # Drop the period + connector = { + "cause": "because", + "effect": "therefore", + }[doc["question"]] + return doc["premise"].strip()[:-1] + f" {connector}" + + +def doc_to_target(doc): + correct_choice = doc["choice1"] if doc["label"] == 0 else doc["choice2"] + # Connect the sentences + return " " + convert_choice(correct_choice) + + +def doc_to_choice(doc): + return [" " + convert_choice(doc["choice1"]), " " + convert_choice(doc["choice2"])] diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/__pycache__/t5_utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/__pycache__/t5_utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..83b92c9cca506f46afc966ad37883834e495f7b1 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/__pycache__/t5_utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..42eba2e1ff86573ee5e9d7e80770dcf2810dcb74 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/default.yaml @@ -0,0 +1,15 @@ +tag: + - super-glue-lm-eval-v1 +task: multirc +dataset_path: aps/super_glue +dataset_name: multirc +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: "{{paragraph}}\nQuestion: {{question}}\nAnswer:" +doc_to_target: label +doc_to_choice: "['''{{answer}}\\nIs the answer correct? yes''', '''{{answer}}\\nIs the answer correct? no''']" +metric_list: + - metric: acc +metadata: + version: 2.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ac948e482e8b708ff176b896c580280d1ec958bb --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/t5-prompt.yaml @@ -0,0 +1,23 @@ +tag: + - super-glue-t5-prompt +task: super_glue-multirc-t5-prompt +dataset_path: aps/super_glue +dataset_name: multirc +training_split: train +validation_split: validation +output_type: generate_until +doc_to_text: "multirc question: {{question}} answer: {{answer}} paragraph: {{paragraph}}" +doc_to_target: label +doc_to_choice: "{% set group_id = idx.question|string %}{{[group_id+'_False', group_id+'_True']}}" +generation_kwargs: + until: + - "" +metric_list: + - metric: !function t5_utils.f1 + aggregation: !function t5_utils.agg_f1 + higher_is_better: true + - metric: !function t5_utils.em + aggregation: !function t5_utils.agg_em + higher_is_better: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/t5_utils.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/t5_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..04f3652b2193bc562ca4a9a067bd803f4f6bdce1 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/multirc/t5_utils.py @@ -0,0 +1,54 @@ +import collections + +import numpy as np + + +def f1(predictions, references): # This is a passthrough function + _prediction = predictions[0] + _reference = references[0].split("_")[-1] + string_label = ["False", "True"] + reference = string_label.index(_reference) + prediction = ( + string_label.index(_prediction) + if _prediction in string_label + else not bool(reference) + ) + + return (prediction, reference) + + +def agg_f1(items): + from sklearn.metrics import f1_score + + predictions, references = zip(*items) + references, predictions = np.asarray(references), np.asarray(predictions) + + return f1_score(references, predictions) + + +def em(predictions, references): # This is a passthrough function + _prediction = predictions[0] + _group, _reference = references[0].split("_") + string_label = ["False", "True"] + reference = string_label.index(_reference) + prediction = ( + string_label.index(_prediction) + if _prediction in string_label + else not bool(reference) + ) + + return (_group, prediction, reference) + + +def agg_em(items): + grouped_values = collections.defaultdict(lambda: ([], [])) + for group, prediction, reference in items: + grouped_values[group][0].append(reference) + grouped_values[group][1].append(prediction) + + group_scores = [] + for group, (targets, predictions) in grouped_values.items(): + score = float(np.array_equal(targets, predictions)) + group_scores.append(score) + + return np.mean(group_scores) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/__pycache__/t5_utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/__pycache__/t5_utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f876afdb0c2b2ffc339241d1e2313e4a9c1e41a3 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/__pycache__/t5_utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/__pycache__/util.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/__pycache__/util.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b6413e42eae45de8aeee25bae7fcec9fd826d8e2 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/__pycache__/util.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1d8dd1786322be2ea30d16f1249aa2ae80db6619 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/default.yaml @@ -0,0 +1,21 @@ +tag: + - super-glue-lm-eval-v1 +task: record +dataset_path: aps/super_glue +dataset_name: record +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: !function util.doc_to_text +doc_to_target: !function util.doc_to_target +doc_to_choice: !function util.doc_to_choice +process_docs: !function util.process_docs +process_results: !function util.process_results +metric_list: + - metric: f1 + aggregation: mean + - metric: em + higher_is_better: True + aggregation: mean +metadata: + version: 2.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d24df1fe4fd83ebd6072231b812c070db7c83292 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/t5-prompt.yaml @@ -0,0 +1,22 @@ +tag: + - super-glue-t5-prompt +task: super_glue-record-t5-prompt +dataset_path: aps/super_glue +dataset_name: record +validation_split: validation +output_type: generate_until +process_docs: !function t5_utils.process_docs +doc_to_text: !function t5_utils.doc_to_text +doc_to_target: "{{idx.passage|string}}+{{idx.query}}_{{answers}}" +generation_kwargs: + until: + - "" +metric_list: + - metric: !function t5_utils.em + aggregation: !function t5_utils.squad_em_agg + higher_is_better: true + - metric: !function t5_utils.f1 + aggregation: !function t5_utils.squad_f1_agg + higher_is_better: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/t5_utils.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/t5_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..e1a29a9498cad497c7f19d4a24b0e55d287992be --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/t5_utils.py @@ -0,0 +1,132 @@ +import collections +import re +import string + +import numpy as np +from datasets import Dataset + +from lm_eval.api.metrics import metric_max_over_ground_truths + + +def doc_to_text(doc): + passage = doc["passage"] + passage = re.sub(r"(\.|\?|\!|\"|\')\n@highlight\n", r"\1 ", passage) + passage = re.sub(r"\n@highlight\n", ". ", passage) + + return " ".join( + [ + "record query:", + doc["query"], + "entities:", + ", ".join(doc["entities"]), + "passage:", + passage, + ] + ) + + +def process_docs(dataset): + def split_answers(doc): + split_doc = { + **{k: [] for k in doc.keys()}, + } + answers = doc.pop("answers") + for idx, answer in enumerate(answers): + for key in split_doc.keys(): + if key in doc: + split_doc[key].append(doc[key]) + + split_doc["answers"].append(answer) + return split_doc + + dataset = dataset.map(split_answers) + new_dataset = {} + for key in dataset.features.keys(): + new_dataset[key] = [x for row in dataset[key] for x in row] + + return Dataset.from_dict(new_dataset) + + +def normalize_squad(answer): + """Normalization used in official SQuAD evaluation script.""" + + def _normalize_answer(text, punc_chars, punc_repl): + """Lower text and remove punctuation, articles and extra whitespace.""" + + def remove_articles(s): + return re.sub(r"\b(a|an|the)\b", " ", s) + + def replace_punctuation(s): + to_replace = set(punc_chars) + return "".join(punc_repl if ch in to_replace else ch for ch in s) + + def white_space_fix(s): + return " ".join(s.split()) + + text = text.lower() + text = replace_punctuation(text) + text = remove_articles(text) + text = white_space_fix(text) + + return text + + return _normalize_answer(answer, punc_chars=string.punctuation, punc_repl="") + + +def em(predictions, references): # This is a passthrough function + return (predictions[0], references[0]) + + +def f1(predictions, references): # This is a passthrough function + return (predictions[0], references[0]) + + +def squad_em_agg(items): + def _exact_match_score(prediction, target): + return target == prediction + + grouped_values = collections.defaultdict(lambda: ([], [])) + for prediction, reference in items: + group, reference = reference.split("_") + # if group not in grouped_values: + grouped_values[group][0].append(normalize_squad(prediction)) + grouped_values[group][1].append(normalize_squad(reference)) + + em = [] + for group in grouped_values.keys(): + predictions, targets = grouped_values[group] + for p in predictions: + em.append(metric_max_over_ground_truths(_exact_match_score, p, targets)) + + return np.mean(em) + + +def squad_f1_agg(items): + def _f1_score(prediction, target): + """Computes token f1 score for a single target and prediction.""" + prediction_tokens = prediction.split() + target_tokens = target.split() + common = collections.Counter(prediction_tokens) & collections.Counter( + target_tokens + ) + num_same = sum(common.values()) + if num_same == 0: + return 0 + precision = 1.0 * num_same / len(prediction_tokens) + recall = 1.0 * num_same / len(target_tokens) + f1 = (2 * precision * recall) / (precision + recall) + return f1 + + grouped_values = collections.defaultdict(lambda: ([], [])) + for prediction, reference in items: + group, reference = reference.split("_") + if group not in grouped_values: + grouped_values[group][0].append(normalize_squad(prediction)) + grouped_values[group][1].append(normalize_squad(reference)) + + f1 = [] + for group in grouped_values.keys(): + p, t = grouped_values[group] + f1.append(metric_max_over_ground_truths(_f1_score, p[0], t)) + + return np.mean(f1) diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/util.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/util.py new file mode 100644 index 0000000000000000000000000000000000000000..252dba44eb1b8a806209b4d5519ea2ba79d12e17 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/record/util.py @@ -0,0 +1,60 @@ +import datasets +import numpy as np +import transformers.data.metrics.squad_metrics as squad_metrics + +from lm_eval.api.metrics import metric_max_over_ground_truths + + +def doc_to_text(doc): + initial_text, *highlights = doc["passage"].strip().split("\n@highlight\n") + text = initial_text + "\n\n" + for highlight in highlights: + text += f" - {highlight}.\n" + return text + + +def format_answer(query, entity): + return f" - {query}".replace("@placeholder", entity) + + +def doc_to_target(doc): + # We only output the first correct entity in a doc + return format_answer(query=doc["query"], entity=doc["answers"][0]) + + +def doc_to_choice(doc): + return [format_answer(query=doc["query"], entity=ans) for ans in doc["entities"]] + + +def process_docs(dataset: datasets.Dataset): + def _process_doc(doc): + return { + "passage": doc["passage"], + "query": doc["query"], + "entities": sorted(list(set(doc["entities"]))), + "answers": sorted(list(set(doc["answers"]))), + } + + return dataset.map(_process_doc) + + +def process_results(doc, results): + # ReCoRD's evaluation is actually deceptively simple: + # - Pick the maximum likelihood prediction entity + # - Evaluate the accuracy and token F1 PER EXAMPLE + # - Average over all examples + max_idx = np.argmax(np.array([result[0] for result in results])) + + prediction = doc["entities"][max_idx] + gold_label_set = doc["answers"] + f1 = metric_max_over_ground_truths( + squad_metrics.compute_f1, prediction, gold_label_set + ) + em = metric_max_over_ground_truths( + squad_metrics.compute_exact, prediction, gold_label_set + ) + + return { + "f1": f1, + "em": em, + } diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/rte/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/rte/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5ad0d3b9d390a98880fc8aeae3393764b3a7a7cd --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/rte/default.yaml @@ -0,0 +1,15 @@ +tag: + - super-glue-lm-eval-v1 +task: sglue_rte +dataset_path: aps/super_glue +dataset_name: rte +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: "{{premise}}\nQuestion: {{hypothesis}} True or False?\nAnswer:" +doc_to_target: label +doc_to_choice: ['True', 'False'] +metric_list: + - metric: acc +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/rte/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/rte/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4920563eed7323a7cf79c696c8057c2d94c88f55 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/rte/t5-prompt.yaml @@ -0,0 +1,22 @@ +tag: + - super-glue-t5-prompt +task: super_glue-rte-t5-prompt +dataset_path: aps/super_glue +dataset_name: rte +training_split: train +validation_split: validation +output_type: generate_until +doc_to_text: "rte hypothesis: {{hypothesis}} premise: {{premise}}" +doc_to_target: label +doc_to_choice: ['entailment', 'not_entailment'] +generation_kwargs: + until: + - "" +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wic/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wic/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2aa3a6105189436447252f915eb5952bda35a081 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wic/default.yaml @@ -0,0 +1,15 @@ +tag: + - super-glue-lm-eval-v1 +task: "wic" +dataset_path: aps/super_glue +dataset_name: wic +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: "Sentence 1: {{sentence1}}\nSentence 2: {{sentence2}}\nQuestion: Is the word '{{sentence1[start1:end1]}}' used in the same way in the two sentences above?\nAnswer:" +doc_to_target: label +doc_to_choice: ['no', 'yes'] +metric_list: + - metric: acc +metadata: + version: 1.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wic/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wic/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8ea1fd73522b55c817500570b52d79a0f1672371 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wic/t5-prompt.yaml @@ -0,0 +1,22 @@ +tag: + - super-glue-t5-prompt +task: super_glue-wic-t5-prompt +dataset_path: aps/super_glue +dataset_name: wic +training_split: train +validation_split: validation +output_type: generate_until +doc_to_text: "wic sentence1: {{sentence1}} sentence2: {{sentence2}} word: {{word}}" +doc_to_target: label +doc_to_choice: ['False', 'True'] +generation_kwargs: + until: + - "" +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/__pycache__/preprocess_wsc.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/__pycache__/preprocess_wsc.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..000ea619507942f16f96a3e0bac668794b5d6915 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/__pycache__/preprocess_wsc.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/__pycache__/t5_utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/__pycache__/t5_utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9e9a44ff42a3d415b8c6eecc7b0a4da785e6a6b1 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/__pycache__/t5_utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/default.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..39abb7f30978bb4923d6fcee8f8046fe7e1778e0 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/default.yaml @@ -0,0 +1,15 @@ +tag: + - super-glue-lm-eval-v1 +task: wsc +dataset_path: aps/super_glue +dataset_name: wsc.fixed +output_type: multiple_choice +training_split: train +validation_split: validation +doc_to_text: !function preprocess_wsc.default_doc_to_text +doc_to_target: label +doc_to_choice: ['no', 'yes'] +metric_list: + - metric: acc +metadata: + version: 1.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/preprocess_wsc.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/preprocess_wsc.py new file mode 100644 index 0000000000000000000000000000000000000000..c62c25676a51fd8e60a4d9fc6f8755041bba7534 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/preprocess_wsc.py @@ -0,0 +1,17 @@ +from lm_eval.utils import general_detokenize + + +def default_doc_to_text(x): + raw_passage = x["text"] + # NOTE: HuggingFace span indices are word-based not character-based. + pre = " ".join(raw_passage.split()[: x["span2_index"]]) + post = raw_passage[len(pre) + len(x["span2_text"]) + 1 :] + passage = general_detokenize(pre + " *{}*".format(x["span2_text"]) + post) + noun = x["span1_text"] + pronoun = x["span2_text"] + text = ( + f"Passage: {passage}\n" + + f'Question: In the passage above, does the pronoun "*{pronoun}*" refer to "*{noun}*"?\n' + + "Answer:" + ) + return text diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/t5-prompt.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/t5-prompt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3ecc67d2a3507867682b13e855e646e9819a336d --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/t5-prompt.yaml @@ -0,0 +1,20 @@ +tag: + - super-glue-t5-prompt +task: super_glue-wsc-t5-prompt +dataset_path: aps/super_glue +dataset_name: wsc.fixed +training_split: train +validation_split: validation +output_type: generate_until +doc_to_text: !function "t5_utils.doc_to_text" +process_results: !function "t5_utils.process_results" +doc_to_target: label +generation_kwargs: + until: + - "" +metric_list: + - metric: accuracy + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/t5_utils.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/t5_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..2860a2a903944a11fff0e981c5135214a8cf8f17 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/super_glue/wsc/t5_utils.py @@ -0,0 +1,104 @@ +import re +from typing import List + + +def doc_to_text(x): + text = re.sub(r" X ", " *" + x["span2_text"] + "* ", _wsc_inputs(x)) + return "wsc: " + text + + +def _wsc_inputs(x): + words = x["text"].split(" ") + + # We would need some special logic to handle the case where the pronoun is the + # first or last word in the text. None of the examples in WSC seem to have + # this, so we are ignoring these cases. + assert x["span2_index"] > 0 + assert x["span2_index"] < len(words) + pronoun_index = x["span2_index"] + + def create_input(): + assert words[pronoun_index] == x["span2_text"] + + return " ".join( + [ + " ".join(words[:pronoun_index]), + "X", + " ".join(words[pronoun_index + 1 :]), + ] + ) + + # Handle some special cases. + if ( + x["text"] + == 'The boy continued to whip the pony , and eventually the pony threw him over. John laughed out quite loud. "Good for him," he said. ' + ): + return ( + "The boy continued to whip the pony , and eventually the pony threw " + 'him over. John laughed out quite loud. "Good for X ," he said.' + ) + + # Using the span2_index, we get 'use' instead of 'it'. + if ( + x["text"] + == "When they had eventually calmed down a bit , and had gotten home, Mr. Farley put the magic pebble in an iron safe . Some day they might want to use it , but really for now, what more could they wish for?" + ): + return ( + "When they had eventually calmed down a bit , and had gotten home, " + "Mr. Farley put the magic pebble in an iron safe . Some day they might " + "want to use X , but really for now, what more could they wish for?" + ) + + return create_input() + + +DETERMINERS = { + "a", + "an", + "few", + "her", + "his", + "each", + "every", + "many", + "much", + "my", + "our", + "some", + "that", + "the", + "their", + "these", + "this", + "those", + "which", + "whose", + "your", +} + + +def clean(s: str) -> str: + """Ignore capitalization and determiners.""" + s = s.strip().lower() + return " ".join([w for w in s.split(" ") if w not in DETERMINERS]) + + +def process_results(docs: dict, resps: List): + prediction = clean(resps[0]) + reference = clean(docs["span1_text"]) + + if ("'" in prediction) != ("'" in reference): + # referent is "Bob's hat" as predicting the referent. + predicted_referent = False + else: + prediction_words = set(prediction.split(" ")) + referent_words = set(reference.split(" ")) + + # Handle cases where the prediction is "fuzzy bunny" and the referent is + # "bunny". + predicted_referent = prediction_words.issubset( + referent_words + ) or referent_words.issubset(prediction_words) + + acc = 1.0 if predicted_referent == docs["label"] else 0.0 + return {"accuracy": acc} diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/swde/__pycache__/task.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/swde/__pycache__/task.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ef1e52eec60752b702a3f52447fe5f44b5a53ded Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/swde/__pycache__/task.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Biology.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Biology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cafd341ba89113f943498641e92d7cb241d054b5 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Biology.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_biology +dataset_name: Biology diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Chemistry.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Chemistry.yaml new file mode 100644 index 0000000000000000000000000000000000000000..42dd1a87d482ed10950a6614d96b2361f57962e4 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Chemistry.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_chemistry +dataset_name: Chemistry diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Geography.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Geography.yaml new file mode 100644 index 0000000000000000000000000000000000000000..110f77ca0e54df0c2653c62a6f461920c7a34476 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Geography.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_geography +dataset_name: Geography diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/History.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/History.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d8350f5ef3497b3194614027a72a1e2539d45a19 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/History.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_history +dataset_name: History diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Mathematics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Mathematics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4318be85929e4f24425c863a21a3e8607956e62a --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Mathematics.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_mathematics +dataset_name: Mathematics diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Philosophy.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Philosophy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4ced0c333fa17ef0b5391103254d130bea9633cd --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Philosophy.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_philosophy +dataset_name: Philosophy diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Physics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9baeb743a782b7bdd906e8e94297a0f85d9a9099 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Physics.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_physics +dataset_name: Physics diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Religion_and_Ethics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Religion_and_Ethics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7513119d5b7504ced4aa6ad818ca257f76a50794 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Religion_and_Ethics.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_religion_and_ethics +dataset_name: Religion_and_Ethics diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Turkish_Language_and_Literature.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Turkish_Language_and_Literature.yaml new file mode 100644 index 0000000000000000000000000000000000000000..552e08b7d6bf41870c6ab3d5a5d3d22c1ce90061 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/Turkish_Language_and_Literature.yaml @@ -0,0 +1,3 @@ +include: _turkishmmlu_default_yaml +task: turkishmmlu_turkish_language_and_literature +dataset_name: Turkish_Language_and_Literature diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/_turkishmmlu_default_yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/_turkishmmlu_default_yaml new file mode 100644 index 0000000000000000000000000000000000000000..e4027f0966f21b1a713678ac898404a44ee43a31 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config/_turkishmmlu_default_yaml @@ -0,0 +1,21 @@ +tag: turkishmmlu +task: null +dataset_path: AYueksel/TurkishMMLU +dataset_name: TurkishMMLU +test_split: test +fewshot_split: dev +fewshot_config: + sampler: first_n +output_type: multiple_choice +doc_to_text: "Soru: {{ question.strip() }}\nA. {{ choices[0] }}\nB. {{ choices[1] }}\nC. {{ choices[2] }}\nD. {{ choices[3] }}\nE. {{ choices[4] }}\nCevap:" +doc_to_choice: ["A", "B", "C", "D", "E"] +doc_to_target: "{{ answer.strip() }}" +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true + - metric: acc_norm + aggregation: mean + higher_is_better: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Biology.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Biology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..98d61be7d7e06b637ee9fec20c615136fc673b63 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Biology.yaml @@ -0,0 +1,54 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_biology +description: + "Soru: AaKkDdEeX$^{R}$X$^{r}$ genotipli bireyde AKD alelleri bağlı olup diğerleri bağımsızdır.\ + \ Bu birey bu karakterler açısından kaç çeşit gamet oluşturabilir? (Krossing over gerçekleşmemiştir.)\nA) 2 \nB)\ + \ 4 \nC) 8 \nD) 16 \nE) 32 \nÇözüm: Adım adım düşünelim.\ + \ Bir bireyde A, K ve D genleri bağımlı olduğunda, bu üç gen birlikte hareket eder ve aynı gamet içinde bulunurlar.\ + \ Diğer lokuslardaki alleller bağımsızdır.\ + \ AKD lokusundaki allel kombinasyonları: AKD veya akd (2 seçenek)\ + \ Diğer lokuslardaki allel kombinasyonları: Ee (2 seçenek), X$^{R}$X$^{r}$ (2 seçenek).\ + \ Şimdi, bağımlı olan AKD lokusundaki kombinasyonu diğer bağımsız lokuslardaki kombinasyonlarla çarpacağız:\ + \ 2 x 2 x 2 = 8\ + \ Bu birey 8 farklı gamet oluşturabilir.\ + \ Doğru cevap C şıkkıdır.\n\nSoru: Aşağıda verilen hormon çiftlerinden hangisi antagonist (zıt) çalışır?\nA) Oksitosin\ + \ - Prolaktin\nB) Kalsitonin - Parathormon\nC) Adrenalin\ + \ - Noradrenalin\nD) Östrojen - Progesteron\nE) FSH - LH\nÇözüm: Adım adım düşünelim.\ + \ Bu soruyu cevaplayabilmek için hormonların görevlerini ve birbirleri ile olan ilişkilerini bilmek gerekir.\ + \ A) Oksitosin ve Prolaktin: Oksitosin doğum sırasında uterus kasılmalarını uyarır ve süt salgılanmasını sağlar. Prolaktin ise süt üretimini uyarır. Bu iki hormon birbirini destekleyici görev yapar, zıt değildir.\ + \ B) Kalsitonin ve Parathormon: Kalsitonin kanda kalsiyum seviyesini düşürür, parathormon ise kalsiyum seviyesini yükseltir. Bu iki hormon birbirine zıt etki gösterir, antagonisttir.\ + \ C) Adrenalin ve Noradrenalin: Her ikisi de stres hormonudur ve benzer görevleri vardır. Zıt etki göstermezler.\ + \ D) Östrojen ve Progesteron: Östrojen kadınlık hormonudur, progesteron ise gebelik sırasında üretilir. Birlikte çalışırlar, zıt etki göstermezler.\ + \ E) FSH ve LH: FSH folikül gelişimini, LH ovulasyonu uyarır. Birlikte çalışırlar, zıt etki göstermezler.\ + \ Dolayısıyla verilen seçenekler arasında antagonist (zıt) çalışan hormon çifti Kalsitonin ve Parathormon'dur.\ + \ Doğru cevap B şıkkıdır.\n\nSoru: I. Besin azalması II. Avcıların artması III. Zehirli madde birikimin artması\ + \ Yukarıdaki faktörlerden hangileri çevre direncini artırır?\nA) Yalnız I\nB) Yalnız II\nC)\ + \ Yalnız III\nD) II ve III\nE) I, II ve III\nÇözüm: Adım adım düşünelim.\ + \ Çevre direnci, bir ekosistemin dışarıdan gelen olumsuz etkilere karşı direncini ifade eder. Yüksek çevre direnci, ekosistemin bu olumsuz etkilere daha iyi direnebileceği anlamına gelir.\ + \ I. Besin azalması, popülasyonların büyümesini ve sağlığını olumsuz etkiler, dolayısıyla çevre direncini artırır.\ + \ II. Avcıların artması, popülasyonların dengesini bozar ve türlerin sayısını azaltır, bu da çevre direncini artırır.\ + \ III. Zehirli madde birikiminin artması, canlıların sağlığını ve üremesini olumsuz etkiler, ekosistemin dengesini bozar, bu şekilde çevre direncini artırır.\ + \ Sorudaki faktörlerin hepsi olumsuz faktörlerdir ve ekosistemin direncini zorlar. Doğru cevap E şıkkıdır.\n\nSoru:\ + \ Gen klonlama çalışmaları sırasında; a. Vektör DNA ve istenen geni taşıyan DNA'nın kesilmesi, b. İstenen geni taşıyan DNA'nın,\ + \ vektör DNA ile birleştirilmesi, c. Bakterinin çoğalmasıyla birlikte istenen genin kopyalanması, uygulamaları yapılmaktadır.\ + \ Bu uygulamalarda; I. DNA polimeraz II. DNA ligaz III. Restriksiyon enzimi yapılarının kullanıldığı çalışma basamakları\ + \ hangi seçenekte doğru olarak verilmiştir?\ + \ I II III \nA) a, b b\ + \ a, c\nB) b a, b c\nC)\ + \ a c a, c\nD) c b, c a\nE)\ + \ b, c a a, b\nÇözüm: Adım Adım düşünelim.\ + \ I. DNA polimeraz: c (Bakterinin çoğalması ile birlikte istenen genin kopyalanması)\ + \ II. DNA ligaz: b, c (İstenen geni taşıyan DNA'nın, vektör DNA ile birleştirilmesi ve sonrasında bakterinin çoğalması ile birlikte kopyalanması)\ + \ III. Restriksiyon enzimi: a (Vektör DNA ve istenen geni taşıyan DNA'nın kesilmesi)\ + \ Doğru cevap D şıkkıdır.\n\nSoru: İnsanlardaki lizozomlar, fagositoz yapmayan hücrelerde de aktif olabilir. Hücreler metabolik faaliyetlerinin sorunsuz geçebilmesi için bazı hücresel yapılarını yıkıp yeniden yapar.\ + \ Hücresel yapıların kontrollü ve programlı şekilde yıkılması lizozomlar tarafından yapılır ve otofaji olarak bilinir.\ + \ Otofaji ile ilgili ifadelerden; I. Otofaji sonucu hücresel yapılar yıkılamadığında lizozomal depolama hastalıkları ortaya çıkar\ + \ II. Otofaji sırasında hidrolitik enzimler hücre dışında etkinlik gösterir\ + \ III. Otofaji olayında hidrolitik enzimler lizozomlarda üretilip sitoplazmaya gönderilir hangileri doğrudur?\nA) Yalnız\ + \ I\nB) I ve II\nC) I ve III\nD) II ve III\nE) I, II ve III\nÇözüm: Adım adım düşünelim.\ + \ I. Otofaji sonucu hücresel yapılar yıkılamadığında lizozomal depolama hastalıkları ortaya çıkar: Doğru\ + \ II. Otofaji sırasında hidrolitik enzimler hücre dışında etkinlik gösterir: Yanlış, hidrolitik enzimler lizozomlarda etkinlik gösterir.\ + \ III. Otofaji olayında hidrolitik enzimler lizozomlarda üretilip sitoplazmaya gönderilir: Yanlış, hidrolitik enzimler lizozomlarda üretilir ve lizozom içinde etkinlik gösterir.\ + \ Doğru cevap A şıkkıdır." +num_fewshot: 0 +dataset_name: Biology diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Chemistry.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Chemistry.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b002bb91f8669cc9d99ac910ebc64049b2e6eb31 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Chemistry.yaml @@ -0,0 +1,86 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_chemistry +description: + "Soru: 16 litre CO ve CO $_{2}$ gaz karışımını yakmak için aynı koşullarda 30 litre hava kullanılmaktadır.\ + \ Buna göre başlangıç karışımındaki VCO\/VCO$_{2}$ oranı aşağıdakilerden hangisidir?(Havanın 1\/5’i oksijen gazıdır.)\nA)\ + \ 3\nB) 3\/8\nC) 2\/3\nD) 1\/5\nE) 1\/3\nÇözüm: Adım adım düşünelim.\ + \ Yakma için kullanılan hava miktarının 1\/5'i oksijen olduğuna göre; 30 litre hava içinde 30*(1\/5) = 6 litre oksijen mevcuttur.\ + \ CO ve CO$_2$ yakmak için gerekli oksijen miktarlarını inceleyelim:CO + 1\/2 O$_2$ → CO$_2$ (Her 1 mol CO için 1\/2 mol O$_2$ gerekir.)\ + \ CO$_2$ yanmaz. Bu durumda, CO'nun yandığını ve tüm 6 litre oksijeni kullandığını varsayalım. 2 mol CO (her biri 22.4 litre/mol standart koşullarda)\ + \ için 1 mol O$_2$ (22.4 litre/mol) gerekiyor. Bu nedenle, 6 litre O$_2$ ile 12 litre CO yakılabilir.\ + \ Bu bilgiyle, başlangıçtaki CO miktarını hesaplayabiliriz. Ancak burada bir yanlış anlama var; zira yakma işlemi\ + \ sonunda sadece CO kullanıldığını farzetmek, CO$_2$'nin başlangıçta orada olmadığını varsayar ki bu doğru değil.\ + \ Soruda CO ve CO$_2$ karışımından bahsedilmektedir, bu nedenle direkt CO kullanımı üzerinden gitmemiz gerek.\ + \ Yakma işlemi CO için geçerli olduğundan ve tüm oksijen CO'nun yanması için kullanıldığından, CO miktarı ve oranı\ + \ direkt olarak hesaplanmalıdır. 6 litre O$_2$, 12 litre CO yakabilir düşüncesi yanlış olmuştur, çünkü her 1 litre CO için 1\/2 litre O$_2$ gerekmektedir.\ + \ Doğru açıklamayla, \\(V_{CO}\\) miktarını \\(x\\) litre ve \\(V_{CO_2}\\) miktarını \\(16 - x\\) litre olarak alalım.\ + \ CO yanmak için 1\/2 oranında O2 kullanır:\ + \ $\\[x \\text{ litre CO} \\times \\frac{1}{2} = \\frac{x}{2} \\text{ litre O}_2\\]$\ + \ Tüm işlemde 6 litre O$_2$ kullanıldığından ve bu O$_2$ yalnızca CO'nun yanması için kullanıldığından,\ + \ $\\(\\frac{x}{2} = 6 \\rightarrow x = 12\\)$. Yani 12 litre CO ve dolayısıyla $\\(16 - 12 = 4\\)$ litre CO$_2$ vardır.\ + \ Bu durumda VCO\/VCO$_2$ oranı $\\(12 / 4 = 3\\)$'tür. Doğru cevap A şıkkıdır.\n\nSoru:\ + \ Aşağıda verilen çözeltilerden hangisinin bileşenlerinin fiziksel halleri doğru verilmiştir?\nÖrnek Çözünen\ + \ Çözücü\nA) Alkollü su Katı Sıvı\nB)\ + \ Tuzlu su Sıvı Katı\nC)\ + \ Gazoz Gaz Sıvı\nD)\ + \ Lehim Gaz Katı\nE)\ + \ Palladyumda hidrojen Katı Gaz\nÇözüm: Adım adım düşünelim.\ + \ Doğru seçenek C şıkkıdır: Gazoz. Gazoz, çözüneni bir gaz (genellikle karbondioksit) ve çözücüsü bir sıvı (su) olan bir çözeltidir. Diğer seçeneklerde çözünen ve çözücü arasındaki fiziksel haller doğru verilmemiştir.\ + \ A şıkkı: Alkollü su; çözünen etanol (alkol) katı değil, sıvı halde ve çözücü su, sıvı halde olmalıdır.\ + \ B şıkkı: Tuzlu su; çözünen tuz (genellikle sodyum klorür) katı, çözücü su ise sıvı halde olmalıdır.\ + \ D şıkkı: Lehim; çözünen katı bir madde (genellikle kalay ve kurşun alaşımı) ve çözücü katı halde olduğunda lehim olarak adlandırılmaz; ısındığında sıvı hale geçer.\ + \ E şıkkı: Palladyumda hidrojen; çözünen hidrojen gazı ve çözücüsü katı bir metal olan palladyum doğru bir açıklamadır fakat soruda istenilen \"çözücü ve çözünenin fiziksel halleri\" açısından en uygun seçenek\ + \ Gazozdur. Doğru cevap C şıkkıdır.\n\nSoru: $_{29}$X$^{2+}$ iyonu ve $_{27}$Y atomu ile ilgili,\ + \ l. s orbitallerindeki elektron sayısı farklıdır. ll. İzoelektronik taneciklerdir. lll. Yarı dolu orbital sayıları eşittir.\ + \ yargılarından hangileri yanlıştır?\nA) l, ll ve lll\nB) ll ve lll\nC) l ve ll\nD) l ve lll\nE) Yalnız lll\nÇözüm: Adım adım düşünelim.\ + \ Bu soruyu çözmek için her iki tanecik $(_{29} \\text{X}^{2+} \\text{ ve } _{27}\\text{Y})$ hakkında bazı bilgileri bilmek gerekmektedir.\ + \ İlk olarak, periyodik cetveldeki yerlerine ve elektron konfigürasyonlarına bakalım.\ + \ - $_{29}$X sembolü ile temsil edilen element Bakır (Cu)’dır ve onun +2 yüklü iyonu $_{29}\\text{Cu}^{2+}$, 29 protona\\ + \ ve 27 elektrona sahip olacaktır. Bakır'ın temel hâli için elektron konfigürasyonu $[Ar] 3d^10 4s^1$ dir,\ + \ ancak 2 elektron kaybettiğinde, 4s orbitalinden ve bir sonraki 3d orbitalinden elektronlar kaybolur ve son konfigürasyon $[Ar] 3d^9$ olur.\ + \ - $_{27}$Y sembolü ile temsil edilen element Kobalt (Co)’dır ve Kobalt'ın nötr atomu, 27 elektrona sahiptir.\ + \ Kobalt'ın elektron konfigürasyonu $[Ar] 3d^7 4s^2$ dir. Şimdi yargılara bakalım:\ + \ l. s orbitallerindeki elektron sayısı farklıdır. Bu doğru, çünkü Cu^{2+} iyonunda 4s orbitali tamamen boşken,\ + \ Co atomunda 4s orbitali 2 elektron içerir.\ + \ ll. İzoelektronik taneciklerdir. Bu yanlış, çünkü izoelektronik tanecikler aynı sayıda elektrona ve\ + \ elektron dizilimine sahiptir. Bu durumda, Cu^{2+} iyonu ve Co atomu izoelektronik değildir.\ + \ lll. Yarı dolu orbital sayıları eşittir. Bu yanlış, çünkü Cu^{2+} yalnızca bir yarı dolu 3d orbitaline (3d^9) sahipken,\ + \ Co atomunda birden fazla yarı dolu 3d orbitali bulunabilir.\ + \ Dolayısıyla, ll ve lll yargıları yanlıştır. Doğru cevap B şıkkıdır.\n\nSoru:\ + \ Elektrolitik metal kaplama, elektrokimyasal metotlar kullanılarak yüzeyde metalik film oluşturulmasıdır.\ + \ Bu işlem malzemenin korozyondan korunması, güzel görünmesi ve yüksek sertlik kazanması gibi amaçlarla uygulanır.\ + \ Aşağıda verilenlerden hangisinde bu yöntem kullanılmamıştır?\nA) Bakır kapların\ + \ kalaylanması.\nB) Araba jantlarının nikel ile kaplanması.\nC) Çeliğin ısıya ve korozyona karşı dayanıklılığını artırmak\ + \ için alüminyum ile kaplanması.\nD) Demir tavanın yüzeyinin teflon ile kaplanması.\nE) Kol saatinin altın\ + \ ile kaplanması.Çözüm: Adım adım düşünelim. Elektrolitik metal kaplama yöntemi, bir metalin başka bir metal ile kaplanmasını içerir.\ + \ Bu yöntem, genellikle elektrokimyasal süreçler kullanılarak yapılır ve metal yüzeyinin korunmasını,\ + \ estetik görünüm kazanmasını veya belirli özellikler elde etmesini amaçlar. Seçenekler arasında bahsedilen\ + \ uygulamalardan Teflon ile kaplama işlemi, elektrolitik bir süreç değildir. Teflon (PTFE),\ + \ metal bir malzeme değil, sıcaklığa ve kimyasallara karşı dirençli bir polimer türüdür. Demir tavanın\ + \ yüzeyinin Teflon ile kaplanması, elektrokimyasal bir yöntem değil, daha ziyade fiziksel veya kimyasal\ + \ buhar biriktirme gibi farklı bir süreç gerektirir.\ + \ Doğru cevap D şıkkıdır.\n\nSoru: Laboratuvarda deney yapan beş arkadaş ile ilgili aşağıdaki bilgiler veriliyor.\ + \ Hasan: Asitler ile çalışılan bir deneyde asitin üzerine su ekliyor.\ + \ İnci: Deney sonrası malzemeleri tezgâhın üzerinde bırakıp deney raporunu yazmaya koyuluyor.\ + \ Nihal: Çözeltinin çökelmesini beklemek için yan masadaki arkadaşlarıyla sohbet ediyor.\ + \ Gülsüm: Kimyasal malzemeler ile çalışırken eldiven giymiyor ve aynı bagetle iki farklı çözeltiyi karıştırıyor.\ + \ Cenk: Sodyum metalinin su ile tepkimesini yaparken gözlerine koruyucu gözlük takıyor.\ + \ Yukarıda verilen bilgilere göre hangi öğrencilerin laboratuvardaki davranışları doğrudur?\nA) Hasan ve Gülsüm\nB) Nihal,\ + \ Gülsüm ve İnci\nC) Hasan ve İnci\nD) Nihal\nE) Cenk\nÇözüm: Adım adım düşünelim.\ + \ Laboratuvarda güvenli çalışmanın bazı kuralları vardır, bu kurallar tehlikeleri azaltmak\ + \ ve güvenli bir çalışma ortamı sağlamak için önemlidir. Öğrencilerin davranışlarını bu kurallar ışığında değerlendirelim:\ + \ - Hasan, asitlerle çalışırken asidin üzerine su ekliyor. Bu işlem çok tehlikelidir çünkü asidin üzerine su eklemek\ + \ yanma ya da patlamaya sebep olabilir. Doğru yöntem, suyun üzerine yavaşça asit eklemektir.\ + \ - İnci, deney sonrası malzemeleri tezgâhın üzerinde bırakıyor ve deney raporuna geçiyor. Laboratuvar güvenliği\ + \ açısından malzemelerin doğru şekilde temizlenmesi ve düzenlenmesi gerekmektedir. Bu yüzden İnci'nin davranışı yanlıştır.\ + \ - Nihal, çözeltinin çökelmesini beklerken yan masadaki arkadaşlarıyla sohbet ediyor. Deney süresince dikkatin\ + \ dağılmaması ve her zaman deney üzerinde kontrolün sağlanması önemli olduğundan, bu davranış doğru olmasa da,\ + \ direkt olarak güvenlikle ilişkili bir hata içermiyor.\ + \ - Gülsüm, kimyasal malzemeler ile çalışırken eldiven giymiyor ve aynı bağetle iki farklı çözeltiyi karıştırıyor.\ + \ Kimyasallarla çalışırken kişisel koruyucu ekipman kullanmak çok önemlidir, bu nedenle eldiven giymemek ve çapraz\ + \ kontaminasyona yol açacak şekilde aynı aracı kullanmak yanlıştır.\ + \ - Cenk, sodyum metalinin su ile tepkimesini yaparken gözlerine koruyucu gözlük takıyor. Bu, doğru bir davranıştır\ + \ çünkü bu tür bir deney sırasında gözleri korumak son derece önemlidir.\ + \ Buna göre, laboratuvardaki doğru davranışları sergileyen öğrenci Cenk'tir. Doğru cevap E şıkkıdır." +num_fewshot: 0 +dataset_name: Chemistry diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Geography.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Geography.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e940a306ac8ad26d231fd96e37b5d223d0de4f0f --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Geography.yaml @@ -0,0 +1,52 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_geography +description: + "Soru: Yerkabuğunu oluşturan levha sınırları ile aşağıdakilerden hangisinin dağılışı paralellik göstermez?\nA) Tektonik depremlerin\nB) Volkanik faaliyetlerin\nC) Kaplıcaların\nD)\ + \ Orman alanlarının\nE) Fay hatlarının\nÇözüm: Adım adım düşünelim.\ + \ Bu soruyu cevaplayabilmek için, levha sınırlarının özelliklerini ve levha hareketlerinin yeryüzündeki etkilerini bilmek gerekir.\ + \ A) Tektonik depremlerin dağılışı, levha sınırlarıyla paralellik gösterir. Levhaların birbirinden uzaklaştığı veya birbirine çarptığı yerlerde depremler meydana gelir.\ + \ B) Volkanik faaliyetlerin dağılışı, levha sınırlarıyla paralellik gösterir. Özellikle açılma (divergent) sınırlarında ve çarpışma (konverjan) sınırlarında volkanik faaliyetler görülür.\ + \ C) Kaplıcaların dağılışı, levha sınırlarıyla paralellik gösterir. Yerkabuğu inceldikçe ve magma yeryüzüne yaklaştıkça kaplıcalar oluşur. Bu da genellikle levha sınırlarında gerçekleşir.\ + \ D) Orman alanlarının dağılışı, levha sınırlarıyla paralellik göstermez. Orman alanlarının dağılışı iklim, toprak yapısı, yükselti gibi faktörlere bağlıdır, doğrudan levha sınırlarıyla ilişkili değildir.\ + \ E) Fay hatlarının dağılışı, levha sınırlarıyla paralellik gösterir. Faylar, levha hareketleri sonucu oluşur ve levha sınırlarına paralel uzanırlar.\ + \ Dolayısıyla, verilen seçeneklerden sadece D şıkkı \"Orman alanlarının\" dağılışı, levha sınırlarıyla paralellik göstermez.\ + \ Doğru cevap D şıkkıdır.\n\nSoru: Geçmişten günümüze değişen iklim koşullarına rağmen, kendi yaşam bölgelerinde varlıklarını\ + \ devam ettiren kalıntı bitkilere..........denir. \ + \ Yukarıdaki boşluğa aşağıdakilerden hangisi getirilirse cümle tamamlanmış olur?\nA)\ + \ Endemik\nB) Relikt\nC) Psödomaki\nD) Antropojen Bozkır\nE) Habitat\nÇözüm: Adım adım düşünelim.\ + \ Bu soruyu cevaplayabilmek için \"relikt\" kavramının ne anlama geldiğini bilmemiz gerekir.\ + \ Relikt bitkiler, geçmiş dönemlerdeki iklim koşullarına uyum sağlamış ve günümüze kadar varlıklarını sürdürebilmiş bitki türleridir.\ + \ Bu bitkiler, çevresel koşullar değişmiş olmasına rağmen özel alanlarda hayatta kalabilmişlerdir.\ + \ Seçeneklere baktığımızda, relikt bitkileri en iyi tanımlayan seçenek B şıkkındaki \"Relikt\" seçeneğidir.\ + \ Doğru cevap B şıkkıdır.\n\nSoru: I. Üretim sürecinde doğanın dengesini bozacak ve\ + \ insan sağlığına zararlı olabilecek kimyasal madde kullanmadan yapılan bir tarım şeklidir. II. Yağışın az, sulamanın yetersiz olduğu alanlarda tarlaların bir yıl ekilip, bir yıl dinlendirilmesi şeklinde uygulanan bir tarım yöntemidir. III. Kış sıcaklık ortalamasının 0 °C’nin altına inmediği yerlerde uygulanan tarım yöntemidir.\ + \ Bu yöntem tarım ürünlerinin mevsimi dışında yetiştirilmesine olanak sağlar. Yukarıda anlatılan tarımsal faaliyetler hangisinde doğru verilmiştir?\ + \ I II III \nA) Organik Nadas Seracılık\nB) Entansif Organik Ekstansif\nC) Seracılık Nadas Organik\nD) Ekstansif Nadas Seracılık\nE)\ + \ Organik Ekstansif Seracılık\nÇözüm: Adım adım düşünelim. Bu soruyu cevaplayabilmek için, verilen tarım yöntemlerinin özelliklerini bilmemiz gerekir.\ + \ Organik tarım, üretim sürecinde doğanın dengesini bozacak ve insan sağlığına zararlı olabilecek kimyasal madde kullanmadan yapılan bir tarım şeklidir.\ + \ Nadas, yağışın az, sulamanın yetersiz olduğu alanlarda tarlaların bir yıl ekilip, bir yıl dinlendirilmesi şeklinde uygulanan bir tarım yöntemidir.\ + \ Seracılık, kış sıcaklık ortalamasının 0 °C’nin altına inmediği yerlerde uygulanan tarım yöntemidir. Bu yöntem tarım ürünlerinin mevsimi dışında yetiştirilmesine olanak sağlar.\ + \ Dolayısıyla, verilen tarım yöntemlerinin doğru karşılıkları şu şekildedir: Organik - Nadas - Seracılık\ + \ Doğru cevap A şıkkıdır.\n\nSoru:\ + \ Yeşilırmak Havzası gelişim projesi ile aşağıdakilerden hangisinin gerçekleşmesi beklenmez?\nA)\ + \ Yeşilırmak'ın akım düzensizliğinden kaynaklanan sel, taşkın, erozyon, su ve çevre kirliliği sorunlarının çözülmesi\nB)\ + \ Otlak alanlarının iyileştirilmesi\nC) Düzenli kentleşmenin sağlanması\nD) Sanayileşmenin\ + \ gerçekleşmesi\nE) Bölgeden çıkarılan ham madde kaynaklarının pazarlanması\nÇözüm: Adım adım düşünelim.\ + \ Yeşilırmak Havzası Gelişim Projesi genellikle bölgedeki çevresel sorunların çözümü, tarım alanlarının geliştirilmesi, su kaynaklarının yönetimi gibi hedeflerle yapılan bir projedir.\ + \ A) Doğru: Projede sel, taşkın, erozyon gibi akım düzensizliğinden kaynaklanan sorunların çözülmesi hedeflenir.\ + \ B) Doğru: Projede otlak alanlarının iyileştirilmesi ve tarım alanlarının geliştirilmesi gibi doğal alanların rehabilitasyonu da önemli bir hedeftir.\ + \ C) Doğru: Projede düzenli kentleşme, altyapı geliştirme gibi şehir planlaması da dikkate alınır.\ + \ D) Doğru: Projenin amaçlarından biri sanayileşmede plansızlığın giderilmesi ve sanayinin gelişmesidir.\ + \ E) Yanlış: Projedenin amaçları arasında ham madde kaynaklarının pazarlanması yer almamaktadır.\ + \ Sonuç olarak, E) Bölgeden çıkarılan ham madde kaynaklarının pazarlanması beklenmez, çünkü projenin amaçları arasında yer almamaktadır.\ + \ Doğru cevap E şıkkıdır.\n\nSoru:\ + \ 1\/2.000.000 ölçekli bir haritada 4 cm olarak gösterilen A-B arasındaki uzaklık başka bir haritada 16 cm olarak gösterilmiştir.\ + \ Buna göre ikinci haritanın ölçeği aşağıdakilerden hangisidir?\nA) 1\/100.000\nB) 1\/200.000\nC) 1\/500.000\nD) 1\/1.500.000\nE)\ + \ 1\/8.000.000\nÇözüm: Adım adım düşünelim.\ + \ İlk haritada 4 cm olarak gösterilen A-B arasındaki uzaklık, ikinci haritada 16 cm olarak gösterilmiştir.\ + \ İlk haritada 4 cm olan uzaklık, ikinci haritada 16 cm olarak gösterildiğine göre, ikinci haritanın ölçeği 4 kat büyüktür.\ + \ İlk haritanın ölçeği 1/2.000.000 olduğuna göre, ikinci haritanın ölçeği 4 kat büyük olduğundan 1/500.000 olacaktır.\ + \ Dolayısıyla, ikinci haritanın ölçeği 1/500.000'dir.\ + \ Doğru cevap C şıkkıdır." +num_fewshot: 0 +dataset_name: Geography diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/History.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/History.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cbb53a5979eeed4e685c124792f4c8f620052d3f --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/History.yaml @@ -0,0 +1,72 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_history +description: + "Soru: Denizcilikte öne çıkan ............. Beyliği Balıkesir bölgesinde kuruldu.\ + \ Osmanlı Devleti’ne .............. döneminde katıldı. Bu beyliğin Osmanlı Devletine katılmasıyla Osmanlı\ + \ Devleti’nde donanma gücü oluşturuldu. Yukarıdaki metinde boş bırakılan yerlere aşağıdakilerden hangisi getirilmelidir?\nA)\ + \ Karesioğulları - Orhan Bey\nB) Hamitoğulları - I. Murat (Hüdavendigar)\nC) Ramazanoğluları\ + \ - I. Selim (Yavuz)\nD) Karamanoğulları - II. Mehmet (Fatih)\nE) Candaroğulları - II. Mehmet (Fatih)\nÇözüm: Adım adım düşünelim.\ + \ Denizcilikte öne çıkan Karesi Beyliği Balıkesir bölgesinde kurulmuştur.\ + \ Osmanlı Devleti'ne katılması ise Orhan Bey döneminde gerçekleşmiştir.\ + \ Bu dönemde Karesi Beyliği'nin Osmanlı'ya katılmasıyla Osmanlı Devleti'nde donanma gücü oluşturulmuştur.\ + \ Doğru cevap A şıkkıdır.\n\nSoru: Osmanlı Devleti’nin kuruluşu ile ilgili birçok tez ortaya atılmıştır.\ + \ Bu tezler arasında birbiriyle benzer fikirler\ + \ olmakla beraber birbirinden oldukça farklı bakış açılarını temsil eden görüşler de ortaya atılmıştır.\ + \ Bu doğrultuda Tarihçi Colin İmber’in görüşleri “Osmanlıların kökenleri hakkındaki eski ya da çağdaş kuramların\ + \ hiçbiri kesinlikle kanıtlanamaz. Osman Gazi hakkındaki geleneksel hikâyelerin neredeyse tümü hayal ürünüdür.\ + \ Çağdaş bir tarihçinin yapabileceği en iyi şey, Osmanlı tarihinin başlangıcının bir kara delikten ibaret\ + \ olduğunu kabul etmek olacaktır.” şeklindedir. Ancak 15. yüzyılda Aşıkpaşazade Osmanlı Tarihi eserini nasıl yazdığını\ + \ şu cümlelerle ifade etmiştir: \"Kendimden önce yazılmış eserleri inceledim. Bu inceleme sonucunda\ + \ önceki dönemleri kaleme aldım.\" Buna göre, Tarihçi Colin İmber ve Aşıkpaşazade’nin görüşleri dikkate\ + \ alındığında aşağıdakilerden hangisine ulaşılamaz?\nA)\ + \ Tarihî meselelerde birbirine zıt görüşler ortaya atılmıştır.\nB) Colin İmber, Osmanlı kuruluş kaynaklarını yetersiz\ + \ görmüştür.\nC) Aşıkpaşazade eserini kaynaklara dayandırmıştır.\nD) Colin İmber, Osman Bey hakkındaki görüşleri\ + \ reddetmiştir.\nE) Osmanlı kuruluşu efsanelere dayanılarak yazılmıştır.\nÇözüm: Adım adım düşünelim.\ + \ Seçenekleri gözden geçirelim:\ + \ A) Tarihi meselelerde birbirine zıt görüşler ortaya atılmıştır.\ + \ - Bu doğru, çünkü Colin İmber ve Asıkpaşazade'nin görüşleri birbirine zıt gibi görünmektedir.\ + \ B) Colin İmber, Osmanlı kuruluş kaynaklarını yetersiz görmüştür. \ + \ - Doğru, çünkü İmber'e göre Osmanlı tarihindeki kaynaklar yetersiz ve hikayeler hayal ürünüdür.\ + \ C) Asıkpaşazade eserini kaynaklara dayandırmıştır. - Doğru, çünkü Asıkpaşazade, eserini kaynaklara dayandırdığını belirtmiştir.\ + \ D) Colin İmber, Osman Bey hakkındaki görüşleri reddetmiştir.\ + \ - Doğru, çünkü İmber, Osman Gazi hakkındaki geleneksel hikayelerin çoğunun hayal ürünü olduğunu belirtmiştir.\ + \ E) Osmanlı kuruluşu efsanelere dayanılarak yazılmıştır.\ + \ - Bu yanlıştır, çünkü Asıkpaşazade'nin eserini kaynaklara dayandırdığı\ + \ ve İmber'in görüşüne göre Osmanlı tarihinin başlangıcının kesin olarak bilinmediği belirtilmiştir.\ + \ Doğru cevap E şıkkıdır.\n\nSoru: Aşağıdakilerden hangisi İstanbul İsyanları’nın sonuçlarından biri değildir?\nA) İstanbul’da\ + \ asayiş ve kamu düzeni bozulmuştur.\nB) Yeniçerilerin devlet içindeki otoritesi artmıştır.\nC) Padişah ve devlet adamlarının\ + \ otoriteleri sarsılmıştır.\nD) Tarımsal üretim azalmış, topraklar boş kalmıştır.\nE) Halkın orduya olan güveni\ + \ azalmıştır.\nÇözüm: Adım adım düşünelim.\ + \ İstanbul İsyanları'nın sonuçlarından biri olarak verilen seçeneklerin hepsi olumlu ya da olumsuz sonuçlar içermektedir.\ + \ Ancak, D seçeneği olan \"Tarımsal üretim azalmış, topraklar boş kalmıştır\" \ + \ İstanbul İsyanları'nın sonuçlarından biri olarak kabul edilmemektedir. İstanbul İsyanları genellikle\ + \ askeri, siyasi ve sosyal sonuçlarla ilişkilendirilir, tarımsal üretimdeki azalma ve toprakların boş\ + \ kalması bu isyanlarla doğrudan bağlantılı değildir.\ + \ Doğru cevap D şıkkıdır.\n\nSoru: SSCB'nin 1991'de dağılmasından sonra Rusya'nın girişimiyle kurulan teşkilat\ + \ aşağıdakilerden hangisidir?\nA) Gümrük Birliği\nB) Avrupa Birliği\nC) Bağımsız Devletler Topluluğu\nD) Şhangay\ + \ Teşkilatı\nE) AGİT\nÇözüm: Adım adım düşünelim.\ + \ Seçenekleri gözden geçirelim: A) Gümrük Birliği - SSCB'nin dağılmasından sonra Rusya'nın girişimiyle kurulan bir teşkilat değildir.\ + \ B) Avrupa Birliği - SSCB'nin dağılmasıyla ilgili değildir ve Rusya'nın girişimiyle kurulmamıştır.\ + \ C) Bağımsız Devletler Topluluğu - SSCB'nin dağılmasından sonra Rusya'nın girişimiyle kurulan bir teşkilattır.\ + \ D) Şangay Teşkilatı - SSCB'nin dağılmasıyla ilgili değildir ve Rusya'nın girişimiyle kurulmamıştır.\ + \ E) AGİT (Avrupa Güvenlik ve İşbirliği Teşkilatı) - SSCB'nin dağılmasıyla ilgili değildir ve Rusya'nın girişimiyle kurulmamıştır.\ + \ Doğru cevap C şıkkıdır.\n\nSoru: Cüveynî “Tarih-i Cihangüşa” adlı eserinde Uygur bölgesini gezerken rastladığı garip\ + \ işaretlerle yazılmış taşlardan söz etmektedir.\ + \ Daha sonra Danimarkalı Messerschmidt’in (Mesırşmit) 1721’de bu eseri görerek Avrupa bilim camiasına tanıtması üzerine birçok bilim adamı\ + \ bu yazıların kime ait olduğu hakkında tahminlerde bulunmuştur. Bu bilim insanlarının bazıları bu yazıların; Prusyalılara, İskitlere,\ + \ Yunanlara ve Latinlere ait olduğunu ileri sürmüştür. Bölgeye giden birçok araştırmacı burada kazılar yaparak yeni kalıntılar tespit etmiştir.\ + \ Kitabelerin okunuşunu ilk çözen Danimarkalı W. Thomsen (V. Tomsen) olmuş, Türklerin yaşantılarına, töresine,\ + \ kültürüne ve devlet yönetimine dair bilgilerle birlikte bu abidelerin Türklere ait olduğunu tüm dünyaya duyurmuştur.\ + \ Metne göre, tarih biliminin aşağıdaki hangi bilim dalından yararlandığı söylenemez?\nA) Arkeoloji\nB)\ + \ Nümizmatik\nC) Epigrafi\nD) Paleografya\nE) Etnografya\nÇözüm: Adım adım düşünelim.\ + \ Metinde, Cuveyni'nin \"Tarih-i Cihanguşa\" adlı eserinde Uygur bölgesinde rastladığı garip işaretlerle yazılmış taşlardan bahsedilmektedir.\ + \ Kitabelerin okunuşunu ilk çözen Danimarkalı W. Thomsen, bu abidelerin Türklere ait olduğunu tüm dünyaya duyurmuştur.\ + \ Bu ifadelerde, epigrafi ve paleografi bilim dallarından bahsedilmektedir.\ + \ Yeni kalıntıların tespitiyle ilgili olarak arkeoloji bilim dalından da bahsedilmektedir.\ + \ Türklerin yaşantılarına, töresine, kültürüne ve devlet yönetimine dair bilgilerin elde edilmesi etnografya bilim dalıyla ilgilidir.\ + \ Nümizmatik, madeni paraları ve metal para basımı tarihini inceleyen bir bilim dalıdır.\ + \ Metinde bahsedilen taşlarla ilgili olarak nümizmatik biliminin bir katkısından bahsedilmemektedir.\ + \ Sonuç olarak, verilen metne göre tarih bilimi, nümizmatik bilim dalından yararlanmamıştır.\ + \ Doğru cevap B şıkkıdır." +num_fewshot: 0 +dataset_name: History diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Mathematics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Mathematics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ff08a1273649a13fca71a3586832fa3f600b4833 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Mathematics.yaml @@ -0,0 +1,74 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_mathematics +description: + "Soru: 3 farklı fizik ve 4 farklı kimya kitabı sıra halinde bir rafa dizilecektir. Fizik veya kimya kitaplarının\ + \ birbirinden ayrılmaması koşuluyla bu kitaplar kaç farklı şekilde dizilebilir\nA) 7.3!.4! \nB) 3.3!.4!\nC) 5.3!.4!\nD)\ + \ 6.3!.4!\nE) 2!.3!.4!\nÇözüm: Adım adım düşünelim. + \ Bu tür soruları çözerken, ilgili koşulları adım adım inceleyerek ilerlemek önemlidir. Bu\ + \ problemde iki önemli koşul var: fizik kitaplarının birbirinden ayrılmaması ve kimya\ + \ kitaplarının birbirinden ayrılmaması gerekmektedir. 1. Adım: Fizik ve kimya kitapları kendi arasında ayrılmaması gerektiği için, tüm fizik\ + \ kitaplarını tek bir grup olarak ve tüm kimya kitaplarını da tek bir grup olarak\ + \ düşünebiliriz. Bu durumda, sadece iki grup olduğu için bu iki grubu sıra halinde\ + \ dizmenin 2! farklı yolu vardır. 2. Adım: Fizik kitapları kendi içinde sıralanabilir. 3 farklı fizik kitabı olduğu için, bu\ + \ kitapları sıralamanın 3! farklı yolu vardır. 3. Adım: Kimya kitapları kendi içinde sıralanabilir. 4 farklı kimya kitabı olduğu için, bu\ + \ kitapları sıralamanın 4! farklı yolu vardır. 4. Adım: Bu durumda, tüm durumların toplam sayısını bulmak için bu\ + \ kombinasyonların çarpımını alırız: 2! . 3! . 4!.\ + \ Doğru cevap E şıkkıdır.\n\nSoru: $(p \\land q')' \\Rightarrow p$ koşullu önermesinin\ + \ karşıtı aşağıdakilerden hangisidir?\nA) $p \\Rightarrow (p \\Rightarrow q)$\nB) $p \\Rightarrow (p \\land q')$\nC)\ + \ $p' \\Rightarrow q$\nD) $q' \\lor p$\nE) $p' \\lor (q \\Rightarrow p)$\nÇözüm: Adım adım düşünelim.\ + \ Verilen koşullu önermenin karşıtını bulmak için, öncelikle verilen koşullu önermeyi ve\ + \ karşıtını gözden geçirelim.\ + \ Verilen koşullu önerme: $(p \\land q')' \\Rightarrow p$\ + \ Bir koşullu önermenin karşıtını bulmak için, koşullu önermenin solundaki ifade (hipotez) ile\ + \ sağdaki ifade (sonuç) yer değiştirilmelidir. Buna göre, verilen önermenin karşıtı:\ + \ $p \\Rightarrow (p \\land q')'$\ + \ $(p \\land q')'$ ifadesini açalım:\ + \ $(p \\land q')' = p' \\lor q$\ + \ $(p \\land q')' = $p \\Rightarrow q$\ + \ Bu durumda, verilen koşullu önermenin karşıtı: $p \\Rightarrow (p \\land q')'$\ + \ $p \\Rightarrow (p \\Rightarrow q)$ şeklinde de ifade edilebilir. \ + \ Doğru cevap A şıkkıdır.\n\nSoru: A oto kiralama firması kiralanacak bir araç için sabit 200 TL\ + \ ve her bir kilometre için 20 kuruş almaktadır. B oto kiralama firması ise kiralanacak bir araç için sabit 140 TL ve her bir kilometre için 25 kuruş almaktadır.\ + \ Buna göre kiralanan birer araçla kaç kilometre yol gidilirse iki firmaya da ödenecek ücret birbirine eşit olur\nA) 1150\nB)\ + \ 1200\nC) 1250\nD) 1300\nE) 1350\nÇözüm: Adım adım düşünelim. A ve B firmalarının uyguladığı ücret planını bir denklemle ifade edebiliriz.\ + \ A firması için toplam maliyet: 200 + 0.20k TL ('k' kilometre için)\ + \ B firması için toplam maliyet: 140 + 0.25k TL\ + \ Bu iki firmaya ödenecek ücretin birbirine eşit olduğu durumu bulmak için bu iki ifadeyi birbirine eşitleriz:\ + \ 200 + 0.20k = 140 + 0.25k\ + \ Bu denklemi çözmek için öncelikle her iki tarafından da '140' çıkarırız ve '0.20k' sapmasını bir tarafa alırız:\ + \ 60 = 0.05k\ + \ Buradan 'k' değerini bulmak için:\ + \ k = 60/0.05 = 1200\ + \ Yani, araçlarla 1200 kilometre yol gidildiğinde iki firmaya da ödenecek ücret birbirine eşit olur.\ + \ Bu nedenle doğru seçenek B: 1200 olacaktır. Doğru cevap B şıkkıdır.\n\nSoru:\ + \ Merkezinin koordinatları M(-1,2) ve yarıçap uzunluğu r=3 birim olan çemberin standart denklemi\ + \ aşağıdakilerden hangisidir?\nA) $\\(\\mathrm{\\left( x-1\\right) ^{2}+\\left( y-2\\right) ^{2}=9}\\)$\nB)\ + \ $\\(\\mathrm{\\left( x-1\\right) ^{2}-\\left( y-2\\right) ^{2}=9}\\)$\nC)\ + \ $\\(\\mathrm{\\left( x+1\\right) ^{2}+\\left( y-2\\right) ^{2}=9}\\)$\nD)\ + \ $\\(\\mathrm{\\left( x+1\\right) ^{2}+\\left( y+2\\right) ^{2}=9}\\)$\nE)\ + \ $\\(\\mathrm{\\left( x+1\\right) ^{2}-\\left( y+2\\right) ^{2}=9}\\)$\nÇözüm: Adım adım düşünelim.\ + \ Çemberin standart denklemi $(x - h)^2 + (y - k)^2 = r^2$ şeklinde ifade edilir, burada\ + \ $(h, k)$ çemberin merkezinin koordinatlarıdır ve $r$ çemberin yarıçapıdır.\ + \ Verilen soruda, çemberin merkezi $M(-1,2)$ ve yarıçapının uzunluğu $r=3$ birim\ + \ olarak belirtilmiştir. Bu değerleri standart denklemde yerine koyalım:\ + \ Merkez $(-1, 2)$ olduğu için, $h = -1$ ve $k = 2$ olur. Yarıçap $r = 3$ birimi olduğu\ + \ için denklem $r^2 = 9$ şekline dönüşür.\ + \ Bunu denkleme yerleştirirsek:\ + \ $(x - (-1))^2 + (y - 2)^2 = 3^2$.\ + \ Bu da şu şekilde basitleştirilir:\ + \ $(x + 1)^2 + (y - 2)^2 = 9$.\ + \ Doğru cevap C şıkkıdır.\n\nSoru:\ + \ $\\(\\large| -8-1\\large| +\\large|-1+6\\large| -\\large|4\\large|\\)$ işleminin sonucu kaçtır?\nA) 2\nB)\ + \ 4\nC) 9\nD) 10\nE) 18\nÇözüm: Adım adım düşünelim.\ + \ Mutlak değer ifadesindeki sayı negatif olsa dahi sonuç pozitif olacaktır. Soruda\ + \ verilen ifadeyi adım adım çözeceğiz:\ + \ $\\large| -8 - 1\\large| + \\large| -1 + 6\\large| - \\large| 4\\large|$\ + \ İlk adımda her bir mutlak değer içindeki işlemi yapalım:\ + \ - $\\large| -8 - 1\\large| = \\large| -9\\large| = 9$ (Mutlak değer içindeki sonuç her\ + \ zaman pozitiftir.)\ + \ - $\\large| -1 + 6\\large| = \\large| 5\\large| = 5$.\ + \ - $\\large| 4\\large| = 4$.\ + \ Böylece ifade şu şekle dönüşür: $9 + 5 - 4$. Sonuç: $9 + 5 - 4 = 10$\ + \ Bu nedenle işlemin sonucu 10'dur. Doğru cevap D şıkkıdır.\n\n" +num_fewshot: 0 +dataset_name: Mathematics diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Philosophy.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Philosophy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3ef5fd615fb7524534c9bf3bfe896efe72363ceb --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Philosophy.yaml @@ -0,0 +1,45 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_philosophy +description: + "Soru: Aşağıdaki ifadelerden hangisi Kant'ın epistemolojik görüşünü yansıtan bir yargıdır?\nA)\ + \ Bilginin kaynağı hem akıl hem deneyimdir.\nB) Doğru bilgi mümkün değildir.\nC) Sezgiye\ + \ dayalı bilgi gerçektir.\nD) Akıl tek başına bilgi elde etmek için yeterlidir.\nE)\ + \ Fenomenlerin bilgisi özseldir.\nÇözüm: Adım adım düşünelim.\ + \ Kant'ın epistemolojik görüşü, bilginin kaynağı olarak hem akıl (yani a priori bilgi) hem de deneyim (a posteriori bilgi) olduğunu öne sürer.\ + \ Doğru cevap A şıkkıdır.\n\nSoru: Bir argümanın ya da argümanı oluşturan önermelerin kendi içinde\ + \ veya birbiriyle uygun olması o argümanın ya daönermenin .................. olduğunu gösterir. Parçadaki boşluğa aşağıdaki\ + \ kavramlardan hangisi getirilmelidir?\nA) Çelişik\nB) Gerçek\nC) Doğru\nD)\ + \ Tutarlı\nE) Geçerli\nÇözüm: Adım adım düşünelim.\ + \ Boşluğa getirilmesi gereken kavram, bir argümanın veya argümanı oluşturan önermelerin kendi içinde veya\ + \ birbiriyle uygun olmasını ifade eden bir kavram olmalıdır. Bu durumda, argümanın veya önermenin tutarlı olduğunu gösterir.\ + \ Doğru cevap D şıkkıdır.\n\nSoru: Bir tek teoloji yoktur. Hemen her dinin kendi teolojisi vardır;\ + \ Hristiyan ve İslam teolojisi gibi. Bunlardan hiçbiri açıklamalarında ait oldukları dinin inanç esaslarının dışına çıkmaz.\ + \ Aşağıdakilerden hangisi bu durumun sebebi olamaz?\nA) Teolojilerin ait oldukları dini baştan doğru kabul\ + \ etmeleri\nB) Teolojilerin din felsefesi gibi dine eleştirel olarak yaklaşmaları\nC) Teolojilerin ait oldukları\ + \ dinin doğruluğunu ispat etme çabaları\nD) Teolojilerin belli bir dini görüşü savunmaya çalışmaları\nE)\ + \ Teolojilerin din felsefesi gibi dinlere tarafsız yaklaşmamaları\nÇözüm: Adım adım düşünelim.\ + \ Bu soruda, verilen ifadelerden hangisinin çeşitli dinlerin kendi teolojilerinin ait oldukları dinin inanç esaslarının dışına\ + \ çıkmadığı durumu açıklamada bir sebep olamayacağı sorulmaktadır. Teolojinin temel amacı, bir dinin inanç esaslarını açıklamak ve yorumlamaktır.\ + \ Dolayısıyla, teolojilerin ait oldukları dini baştan doğru kabul etmeleri A), belli bir dinin görüşünü savunmaya çalışmaları, D)\ + \ ait oldukları dinin doğruluğunu ispat etme çabaları C) ve din felsefesi gibi dinlere tarafsız yaklaşmamaları E) bu durumun sebepleri olabilir.\ + \ Ancak, din felsefesi gibi dine eleştirel olarak yaklaşmaları B) ise teolojik çalışmaların temel amaçlarından biri değildir.\ + \ Doğru cevap B şıkkıdır. \n\nSoru: Konfüçyüs’a göre “Zenginlik ve şeref herkesin istediği şeylerdir. Eğer bunlar doğru bir yolda\ + \ kazanılmazsa pek çabuk kaybedilir. Fakirlik ve düşkünlük insanların nefret ettiği şeylerdir. Eğer insanlar dürüst davranmazlarsa\ + \ kendilerini bunlardan sıyırmalarının imkânı yoktur.” Bu açıklama ile Konfüçyüs, felsefenin hangi konusuna vurgu\ + \ yapmıştır?\nA) Bilgi\nB) Spor\nC) Varlık\nD) Siyaset\nE) Ahlak\nÇözüm: Adım adım düşünelim.\ + \ Konfüçyüs'ün bu açıklamasında vurgu yaptığı temel konu, insan davranışlarının doğruluğuyla ilgilidir.\ + \ Konfüçyüs, zenginlik, şeref, fakirlik ve düşkünlük gibi dışsal değerlerin kazanılmasının doğru bir şekilde sağlanmaması durumunda\ + \ hızlıca kaybedilebileceğini, ancak insanların dürüst davranışlar sergilemediği sürece bu tür olumsuzluklardan kaçmanın mümkün olmadığını vurgular.\ + \ Dolayısıyla, Konfüçyüs'ün bu açıklamasıyla vurguladığı konu ahlaktır.\ Doğru cevap E şıkkıdır.\n\nSoru:\ + \ İnancın temele alındığı MS 2- MS 15. yüzyıl felsefesi, kendinden önceki dönem felsefelerinden etkilenmiştir.\ + \ Örneğin Hristiyan filozofları, Hristiyanlığı yaymak için diriliş inancını destekleyen ruhun ölmemesi hatta tekrar dirilmesi\ + \ fikrini savunan Antik Yunan filozofunun görüşlerinden; İslam filozofları ise Tanrı’nın varlığı kanıtlamalarında\ + \ başka bir Antik Yunan filozofunun geliştirdiği mantıktan yararlanmışlardır. Bu parçaya göre, MS 2- 15. yüzyıl\ + \ felsefesini etkileyen filozoflar sırasıyla aşağıdaki seçeneklerden hangisinde verilmiştir?\nA)\ + \ Epiküros, Aristoteles\nB) Epiküros, Platon\nC) Platon, Aristoteles\nD) Platon, Epiküros\nE)\ + \ Aristoteles, Platon\nÇözüm: Adım adım düşünelim.\ + \ Parçada belirtilenler doğrultusunda, Hristiyan filozoflarının diriliş inancını desteklemek için Antik Yunan filozoflarının ruhun ölmemesi\ + \ ve hatta tekrar dirilmesi fikrini savunan görüşlerinden etkilendiği ifade edilmiştir. Bu görüşleri savunan Antik Yunan filozofunun Platon olduğu bilinmektedir.\ + \ İslam filozoflarının ise Tanrı'nın varlığını kanıtlamada başka bir Antik Yunan filozofunun mantığından yararlandığı ifade edilmektedir\ + \ ve bu filozofun da Aristoteles olduğu bilinmektedir. Doğru cevap C şıkkıdır." +dataset_name: Philosophy diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Physics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25d8eff98ad1e9583e556972a574f6ecfca88c65 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Physics.yaml @@ -0,0 +1,106 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_physics +description: + "Soru: 20°C sıcaklığında R direncine sahip silindirik bakır tel eritilerek boyu ilk boyunun iki katı kadar ve yine\ + \ silindirik olacak biçimde yeni bir kalıba dökülüyor. Bu durumda yeni telin direnci kaç R olur?\nA)\ + \ 4\nB) 2\nC) 1\nD) 1/2\nE) 1/4\nÇözüm: Adım adım düşünelim.\ + \ Yeni direncin değerini bulmak için öncelikle direncin nasıl değiştiğini anlamamız gerekiyor.\ + \ Direnç \\(R\\), iletkenin direncinin uzunluğu \\(l\\), kesit alanı \\(A\\) ve\ + \ malzemenin özdirenci (veya direnç katsayısı) \\(\\rho\\) ile doğrudan ilişkilidir ve\ + \ aşağıdaki formülle ifade edilir:\ + \ \\[R = \\rho \\frac{l}{A}\\]\ + \ Bu denklemde görüldüğü üzere, direnç iletkenin uzunluğu ile doğru orantılıyken,\ + \ kesit alanı ile ters orantılıdır. Soruda verilenler doğrultusunda, bakır telin uzunluğu iki\ + \ katına çıkarılıyor, bu durumda yeni uzunluğumuz \\(2l\\) olacaktır. Bakır telin hacmi\ + \ değişmediğinden ve şekli de yine silindirik olduğundan, bu durumda kesit alan da\ + \ değişmek zorundadır; çünkü uzunluk iki katına çıkartıldığında, hacmi korumak için\ + \ kesit alanın yarıya düşürülmesi gerekiyor. Yeni kesit alanımız \\(A/2\\) olacaktır.\ + \ Yeni direnç \\(R'\\) şu şekilde hesaplanır:\ + \ \\[R' = \\rho \\frac{2l}{A/2} = 4 \\times \\rho \\frac{l}{A}\\]\ + \ Bu durumda, yeni direnç \\(R'\\) orijinal direnç \\(R\\) ile karşılaştırıldığında 4 katına\ + \ çıkmış olur. Doğru cevap A şıkkıdır.\n\nSoru: Karayip resif mürekkep balığı suyun üstünde 2 m yüksekliğe çıkmak\ + \ ve vücut uzunluğunun 50 katı kadar bir mesafeye yani toplamda 10 m uçmak için tepkili itme kullanır.\ + \ Bunun için vücuduna düşük hızda aldığı akışkan ile kütlesini arttırıp, sonra bu akışkanı yüksek hızda dışarı atarak kütlesini azaltır. Mürekkep balığının kullandığı\ + \ bu yöntem roketleri fırlatmak için ihtiyaç duyulan itiş gücünün temel mantığını oluşturur. Örneğin yükünü\ + \ kaldırabilecek yeterli itiş kuvvetinin sağlanabilmesi için Atlas V roketinde, saniyede 1000 kg’dan fazla yakıt\ + \ tüketilmesi ve egzoz gazının saniyede 4000 m süratle dışarı atılması gerekmiştir. Yer çekimine karşı yapılan bu\ + \ fırlatma işlemi rokete uçuş süresi boyunca gerekli yakıtın sağlanması ve yer çekiminden kurtulmak için saatte 40000 km gibi bir sürate ulaşması\ + \ ile mümkün olabilmektedir. Aşağıdakilerden hangisinde ya da hangilerinde\ + \ yukarıdaki metinde geçen duruma örnek verilebilir?\nI. Şişirilen balonun serbest bırakılması. II. Ateşlenen top aracının geriye doğru hareket etmesi.\ + \ III. Havada patlayan havai fişeği parçalarının farklı yönlerde ilerlemesi. IV.\ + \ Hareketli bir bilardo topu ile duran bilardo topunun hareket ettirilmesi\nA) Yalnız I\nB)\ + \ Yalnız II\nC) I ve II\nD) II ve IV\nE) I, II ve IV\nÇözüm: Adım adım düşünelim.\ + \ Yukarıdaki metinde anlatılan durum, bir cismin içerisinden hızla dışarı atılan akışkan veya gaz sayesinde\ + \ ters yönde bir itiş gücü üretilmesini ve bu sayede ileri hareket edilmesini içerir. Bu durum, roketlerin fırlatılma\ + \ prensibi ve Karayip resif mürekkep balığının hareket mekanizması ile örneklendirilmiştir. Verilen seçenekler göz önünde\ + \ bulundurulduğunda: \ + \ I. Şişirilen balonun serbest bırakılması - Bu durum, balonun içindeki hava dışarıya hızla atıldığında balonun ters yönde\ + \ hareket etmesi prensibine dayanır, bu nedenle ilgili durumla benzerdir. \ + \ II. Ateşlenen top aracının geriye doğru hareket etmesi - Bu, Newton'un üçüncü yasası (her eyleme karşılık eşit ve zıt\ + \ yönde bir tepki olur) örneğidir ve roketin veya mürekkep balığının hareketine benzer bir durumdur. Ateşlenen top, bir yöne doğru\ + \ kuvvet uyguladığında, top aracı da zıt yönde bir kuvvetle hareket eder.\ + \ III. Havada patlayan havai fişeğin parçalarının farklı yönlere ilerlemesi - Bu, içeriden\ + \ dışarıya bir patlama etkisi ile nesnelerin her yöne dağılmasını içerir ve itme\ + \ kuvvetinin her yöne eşit dağıldığı bir durumu ifade eder. Bu örnek, direkt olarak\ + \ içeriden dışarıya hızlı bir akışkan veya gazın atılması ile ileri hareket etme prensibini\ + \ taşımaz.\ + \ IV. Hareketli bir bilardo topu ile duran bilardo topunun hareket ettirilmesi - Bu, iki katı\ + \ cismin çarpışması durumunu ve momentumun korunumu ilkesini içerir, direkt olarak\ + \ itiş kuvveti prensibi ile ilgili değildir.\ + \ Böylece, açıklanan prensiplere en çok uyan seçenek I. ve II. durumları içeren seçenek doğrudur.\ + \ Doğru cevap C şıkkıdır.\n\nSoru: Yay sabiti k olan yay sarkacı ve ip uzunluğu $\\(\\ell\\)$ olan basit sarkaçtan oluşturulan\ + \ sistemler yerçekimi ivmesinin daha büyük olduğu bir gezegene götürülürse periyotları nasıl değişir?\nYay Sarkacı Basit Sarkaç\nA) Değişmez Artar\nB) Değişmez Değişmez\nC) Azalır\ + \ Değişmez\nD) Artar Azalır\nE) Değişmez Azalır\nÇözüm: Adım adım düşünelim.\ + \ Yay sarkacının periyodu, yay sabiti \\(k\\) ve sarkacın kütlesi \\(m\\) ile ilişkili olup\ + \ \\(T = 2\\pi\\sqrt{\\frac{m}{k}}\\) formülüyle hesaplanır. Yerçekimi ivmesi (\\(g\\)) bu formülde yer almadığından, yay sarkacının\ + \ periyodu yerçekimi ivmesinin değerinden bağımsızdır ve değişmez. \ + \ Basit sarkacın periyodu ise \\(T = 2\\pi\\sqrt{\\frac{\\ell}{g}}\\) formülüyle hesaplanır. Bu formülde \\(\\ell\\) ipin uzunluğunu\ + \ ve \\(g\\) yerçekimi ivmesini temsil eder. Eğer yerçekimi ivmesi \\(g\\) büyükse, denklemin paydası büyüyeceğinden, periyodun\ + \ değeri azalır. Bu durumda, yay sarkacının periyodu değişmezken, basit sarkacın periyodu azalır.\ + \ Doğru cevap E şıkkıdır.\n\nSoru: 100 g kütleli bir kap özkütlesi 1 g/cm $^{3}$ olan su ile dolu iken kütlesi 350 g oluyor.\ + \ Buna göre, kap 0,5 g/cm$^{3 }$özkütleli sıvı ile doldurulursa kütlesi kaç g olur?\nA) 75\nB)\ + \ 125\nC) 175\nD) 225\nE) 250\nÇözüm: Adım adım düşünelim.\ + \ Kap ve suyun birleşik kütlesi 350 g olduğuna göre, sadece suyun kütlesini bulabilmek için kapın kütlesini bu değerden\ + \ çıkarmamız gerekiyor. Kap zaten boşken 100 g olduğuna göre: \ + \ Su + kap = 350 g\ + \ Su = 350 g - kap\ + \ Su = 350 g - 100 g\ + \ Su = 250 g\ + \ Bu, kapın içerisine koyduğumuz suyun kütlesinin 250 g olduğunu gösterir. Su için\ + \ verilen özkütlesi 1 g/cm$^{3}$ olduğuna göre ve kütlesi 250 g ise hacmi de 250\ + \ cm$^{3}$ olmalıdır (çünkü kütlesi özkütlesi ile çarpıldığında hacmini verir).\ + \ Şimdi, 0,5 g/cm$^{3}$ öz kütleli bir sıvı ile aynı kapı doldurursak, aynı hacmi (250\ + \ cm$^{3}$) dolduracağını varsayabiliriz. Bu sıvının kütlesini bulmak için hacmi öz\ + \ kütlesi ile çarpalım:\ + \ Kütle = özkütle * hacim\ + \ Kütle = 0,5 g/cm$^{3}$ * 250 cm$^{3}$\ + \ Kütle = 125 g\ + \ Bu yeni sıvının kütlesi 125 g olacaktır. Ancak bu sadece sıvının kütlesi. Toplam\ + \ kütleyi bulmak için kapın kütlesini (100 g) de eklememiz gerekiyor:\ + \ Toplam kütle = sıvı + kap\ + \ Toplam kütle = 125 g + 100 g\ + \ Toplam kütle = 225 g\ + \ Buna göre, kap 0,5 g/cm$^{3}$ özkütleli sıvı ile doldurulursa toplam kütlesi 225 g olur.\ + \ Doğru cevap D şıkkıdır.\n\nSoru: Sıcaklık için aşağıda verilenlerden hangisi doğrudur?\nA)\ + \ Bir enerji çeşitidir.\nB) Termometre ile ölçülür.\nC) Birimi\ + \ kaloridir.\nD) Madde miktarına bağlıdır.\nE) Birimi joule' dür.\nÇözüm: Adım adım düşünelim.\ + \ Sıcaklığın ne olduğunu ve nasıl ölçüldüğünü ele alarak, verilen seçenekleri inceleyelim:\ + \ A) \"Bir enerji çeşididir.\" - Bu ifade doğru değildir. Sıcaklık, enerjinin bir çeşidi değil,\ + \ malzemenin veya cismin ortalama kinetik enerjisinin bir ölçüsüdür. Dolayısıyla,\ + \ enerjinin bir türü olarak değil, enerjinin belli bir durumunu ifade eder.\ + \ B) \"Termometre ile ölçülür.\" - Bu ifade doğrudur. Sıcaklık termometre gibi özel\ + \ aygıtlar kullanılarak ölçülür. Bu aygıtlar, farklı sıcaklık değerlerinde farklı tepkiler verir\ + \ ve bu sayede sıcaklığın ne olduğunu belirleyebiliriz.\ + \ C) \"Birimi kaloridir.\" - Bu ifade yanlıştır. Kalori, enerji birimidir ve özellikle ısı\ + \ enerjisinin miktarını ölçmek için kullanılır. Sıcaklığın birimi ise derece Celsius (°C), derece\ + \ Fahrenheit (°F), veya Kelvin (K) gibi ölçü birimleridir.\ + \ D) \"Madde miktarına bağlıdır.\" - Bu ifade yanlıştır. Sıcaklık, bir maddenin miktarından\ + \ bağımsız, maddenin ortalama kinetik enerjisinin bir ölçüsüdür. Yani, madde miktarı\ + \ sıcaklığı doğrudan etkilemez; aynı sıcaklıktaki iki farklı miktar madde, biri fazla biri az\ + \ olsa dahi, aynı sıcaklığa sahip olabilir.\ + \ E) \"Birimi joule'dür.\" - Bu ifade de yanlıştır. Joule, enerjinin SI birimidir ve sıcaklığın\ + \ birimi değildir. Daha önce belirtildiği gibi, sıcaklığın birimi derece Celsius, derece\ + \ Fahrenheit veya Kelvin'dir.\ + \ Doğru cevap B şıkkıdır." +num_fewshot: 0 +dataset_name: Physics diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Religion_and_Ethics.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Religion_and_Ethics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a81b9b803e81626fd6ff15bd56a40794247c443e --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Religion_and_Ethics.yaml @@ -0,0 +1,51 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_religion_and_ethics +description: + "Soru: (I) Allah’a (c.c.) inanmak insanın hayatında olumlu değişiklikler yapar. (II) Bunun nedeni imanın; duygu, düşünce ve davranışlar üzerinde etkili olmasıdır.\ + \ (III) İnsanın Allah (c.c.) ile irtibatı dua, ibadet, tövbe ve Kur’an okuma gibi yollarla gerçekleşir. (IV) İnsan büyük oranda inancına göre görür, düşünür ve davranışlar sergiler.\ + \ (V) Bu durumu açıklayan birçok ayet ve hadis bulunmaktadır. Bu parçadaki numaralanmış cümlelerden hangisi düşüncenin akışını bozmaktadır?\nA)\ + \ I\nB) II\nC) III\nD) IV\nE) V\nÇözüm: Adım adım düşünelim.\ + \ Metinde düşüncenin akışını bozan cümle C) III'dür. Çünkü diğer cümleler imanın insan üzerindeki etkilerine odaklanırken,\ + \ III numaralı cümle insanın Allah ile irtibatını nasıl gerçekleştirdiğine dair bir açıklama sunar, bu da ana fikrin akışını biraz keser. \ + \ Doğru cevap C şıkkıdır.\n\nSoru: İslam ahlakının kaynağı aşağıdakilerden hangisidir?\nA)\ + \ Kur’an ve sünnet\nB) Birey ve toplum\nC) Terbiye ve deneyim\nD)\ + \ Akıl ve düşünce\nE) Vicdan ve bilgi\nÇözüm: Adım adım düşünelim.\ + \ İslam ahlakının kaynağı \"Kur'an ve Sünnet\"tir. \ + \ Kur'an, İslam'ın kutsal kitabıdır ve peygamberin sözleri, eylemleri ve onayladıkları olan sünnet, İslam ahlakının temelini oluşturur.\ + \ Doğru cevap A şıkkıdır.\n\nSoru: Dinimizin ibadetler konusunda önem verdiği temel ilkelerden biri ihlastır.\ + \ Dolayısıyla İslami açıdan ibadetlerin, sadece Yüce Allah’ın (c.c.) rızasını kazanmak amacıyla yapılması esastır.\ + \ Mümin, her zaman bu bilinçte olmalıdır.\nİbadetlerini bu bilinçle, severek, isteyerek ve samimiyetle yapmalıdır.\ + \ Nitekim bizler her gün namazlarda okuduğumuz Fâtiha suresinde, ---- diyerek bunu ifade ediyoruz.\ + \ Verilen parçada boş bırakılan yere aşağıdaki ayetlerden hangisi getirilmelidir?\nA)\ + \ “Rahmân ve rahîm olan Allah’ın adıyla.” (Fâtiha suresi, 1. ayet.) \nB)\ + \ “Hamd (övme ve övülme), âlemlerin Rabbi Allah’a mahsustur. ” (Fâtiha suresi, 2. ayet.) \nC)\ + \ “O, rahmândır ve rahîmdir. Ceza gününün malikidir. ” (Fâtiha suresi, 3-4. ayetler.) \nD)\ + \ “Yalnız sana ibadet eder ve yalnız senden yardım dileriz.” (Fâtiha suresi, 5. ayet.) \nE)\ + \ “Bize doğru yolu göster. ” (Fâtiha suresi, 6. ayet.)\nÇözüm: Adım adım düşünelim. \ + \ Verilen parçada ifade edildiği gibi, İslami ibadetlerin temel amacı Allah'ın rızasını kazanmaktır ve bu amaçla ibadetlerin ihlas ile yapılması önemlidir. Namazlarda okunan Fatiha suresinde bu bilinci ifade eden bir ayet bulunmaktadır.\ + \ Fatiha suresinin ayetleri şunlardır:\ + \ Rahmân ve Rahîm olan Allah'ın adıyla.\ + \ Hamd (övme ve övülme) âlemlerin Rabbi Allah'a mahsustur.\ + \ O, Rahmân'dır ve Rahîm'dir.\ + \ Ceza gününün malikidir. \ + \ Yalnız sana ibadet eder ve yalnız senden yardım dileriz.\ + \ Bize doğru yolu göster.\ + \ İbadetlerin ihlas ile yapılması ve sadece Allah'ın rızasını gözeterek gerçekleştirilmesi kavramını ifade eden ayet ise D) Yalnız sana ibadet eder ve yalnız senden yardım dileriz. şeklindeki 5. ayettir.\ + \ Doğru cevap D şıkkıdır.\n\nSoru: Müminler ancak kardeştirler. Öyleyse kardeşlerinizin arasını düzeltin.\ + \ Allah’a karşı gelmekten sakının ki size merhamet edilsin.” (Hucurât suresi, 10. ayet.) Ayetin asıl konusu nedir?\nA)\ + \ Adalet\nB) Kardeşlik\nC) İtaat\nD) Bağışlama\nE) Sorumluluk\nÇözüm: Adım adım düşünelim.\ + \ Bu ayetin asıl konusu \"Kardeşlik\"tir. Çünkü ayette müminlerin birbirlerine kardeş oldukları\ + \ ve aralarındaki ilişkilerin düzeltilmesi gerektiği vurgulanır. Doğru cevap B şıkkıdır.\n\nSoru:\ + \ İslam medeniyeti, Emeviler döneminde oluşum sürecine girmiş, Abbasiler döneminde gelişmiş, Selçuklular döneminde bu gelişim devam etmiş, \ + \ Osmanlı döneminde ise kurum ve kuruluşlarıyla en parlak devrini yaşamıştır. İslam medeniyetinin mimari, edebiyat, sanat, matematik, astronomi, tıp vb. \ + \ alanlarda ortaya koyduğu örnekler oldukça fazladır. Farabi, İbn Sina, Biruni, Harezmî, İbn Rüşd, İbn Haldun gibi ilim adamları kendi dönemlerinde, felsefe, mantık, matematik,\ + \ tıp, astronomi gibi alanlarda tüm dünyaya zengin ilmi ürünler sunmuşlardır. Bu parçanın ana konusu aşağıdakilerden hangisidir?\nA)\ + \ Medeniyetin en önemli unsurları\nB) Medeniyete katkı sağlayan İslam âlimleri\nC)\ + \ İslam medeniyetiyle ortaya çıkan kurumlar\nD) İslam medeniyetinin en parlak dönemleri\nE)\ + \ İslam medeniyetinin oluşma süreci\nÇözüm: Adım adım düşünelim.\ + \ Bu parçanın ana konusu, İslam medeniyetinin gelişimini ve etkisini tanımlayan bir açıklamadır.\ + \ Parça, İslam medeniyetinin Emeviler, Abbasiler, Selçuklular ve Osmanlılar dönemlerindeki oluşumunu ve gelişimini kapsamlı bir şekilde ele alırken,\ + \ İslam medeniyetinin farklı alanlardaki önemli katkılarını ve ilim adamlarının rollerini vurgular.\ + \ Doğru cevap E şıkkıdır." +dataset_name: Religion_and_Ethics +num_fewshot: 0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Turkish_Language_and_Literature.yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Turkish_Language_and_Literature.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2e1ee51ae39475693de41fff1a0da13cb10ac466 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/Turkish_Language_and_Literature.yaml @@ -0,0 +1,59 @@ +include: _turkishmmlu_cot_default_yaml +task: turkishmmlu_cot_turkish_language_and_literature +description: + "Soru: Aşağıdakilerden hangisi edebiyat tarihinin konuları arasında yer almaz?\nA) Edebî dönemler\nB)\ + \ Şair ve yazarların edebî kişiliği\nC) Şair ve yazarların hayatları\nD) Edebî eserler\nE)\ + \ Arkeolojik eserler\nÇözüm: Adım adım düşünelim.\ + \ Edebiyat tarihinin konularını gözden geçirelim:\ + \ A) Edebî dönemler - Edebiyat tarihi, farklı edebi dönemleri ve bu dönemlerdeki edebi akımları inceler.\ + \ B) Şair ve yazarların edebî kişiliği - Edebiyat tarihi, şair ve yazarların eserlerindeki temaları, tarzları ve edebi kişiliklerini de ele alır.\ + \ C) Şair ve yazarların hayatları - Edebiyat tarihi, şair ve yazarların biyografilerini ve hayat hikayelerini de inceler.\ + \ D) Edebî eserler - Edebiyat tarihi, farklı edebi eserleri, bu eserlerin türlerini, temalarını ve döneminin özelliklerini inceler.\ + \ E) Arkeolojik eserler - Edebiyat tarihi, genellikle arkeolojik eserlerle ilgilenmez. Arkeolojik eserler,\ + \ arkeoloji biliminin konusudur ve genellikle tarih ve kültürel antropoloji alanlarında incelenir.\ + \ Sonuç olarak, edebiyat tarihinin konuları arasında yer almayan (farklı bir alana ait olan) seçenek E) Arkeolojik eserlerdir.\ + \ Doğru cevap E şıkkıdır.\n\nSoru: Osmanlı Devleti'nin son döneminde ortaya çıkan düşünce akımlarının\ + \ temsilcileri hangi seçenekte doğru verilmiştir?\nA) İslamcılık: Sait Halim Paşa, Mehmet Emin Yurdakul\nB)\ + \ Türkçülük: Ziya Gökalp, Ömer Seyfettin\nC) Batıcılık: Tevfik Fikret, Eşref Edip\nD) Osmanlıcılık:\ + \ Mehmet Akif Ersoy, Sait Halim Paşa\nE) Medeniyetçilik: Münif Paşa, Ali Canip Yöntem\nÇözüm: Adım adım düşünelim.\ + \ Osmanlı Devleti'nin son döneminde ortaya çıkan düşünce akımlarının temsilcilerini inceleyelim:\ + \ A) İslamcılık: Sait Halim Paşa, Mehmet Emin Yurdakul - İslamcılık akımının temsilcileri arasında Sait Halim Paşa ve Mehmet Emin Yurdakul yer almamaktadır.\ + \ B) Türkçülük: Ziya Gökalp, Ömer Seyfettin - Türkçülük akımının önde gelen temsilcileri arasında Ziya Gökalp ve Ömer Seyfettin bulunmaktadır. Bu seçenek doğru görünmektedir.\ + \ C) Batıcılık: Tevfik Fikret, Eşref Edip - Batıcılık akımının temsilcileri arasında Tevfik Fikret ve Eşref Edip bulunmamaktadır.\ + \ D) Osmanlıcılık: Mehmet Akif Ersoy, Sait Halim Paşa - Osmanlıcılık akımının temsilcileri arasında Mehmet Akif Ersoy ve Sait Halim Paşa bulunmamaktadır.\ + \ E) Medeniyetçilik: Münif Paşa, Ali Canip Yöntem - Medeniyetçilik akımının temsilcileri arasında Münif Paşa ve Ali Canip Yöntem bulunmamaktadır.\ + \ Doğru cevap B şıkkıdır.\n\nSoru: Birçok edebiyatçı ve eleştirmene göre şairlik yeteneği Tevfik Fikret'ten bile daha ileridedir.\ + \ Fakat siyasi görüşleri daima sanatının önünde yer almıştır.\ + \ Millî Mücadele Dönemi'nde Anadolu hareketini eleştirmiş, saltanat yanlısı görüşler ortaya koymuştur. Cumhuriyet Dönemi'nde de siyasi fikirleri yüzünden çokça eleştirilmiştir.\ + \ Parçada bahsedilen Servetifünun şairi aşağıdakilerden hangisidir?\nA) Süleyman Nazif\nB) Hüseyin Cahit Yalçın\nC) Mehmet Rauf\nD) Cenab\ + \ Şahabettin\nE) Halit Ziya Uşaklıgil\nÇözüm: Adım adım düşünelim.\ + \ Parçada bahsedilen şairin siyasi görüşlerinin sanatından daha önde olduğu ve Milli Mücadele Dönemi'nde Anadolu hareketini eleştirdiği,\ + \ saltanat yanlısı görüşler ortaya koyduğu ve Cumhuriyet Dönemi'nde de siyasi fikirleri nedeniyle eleştirildiği belirtilmektedir.\ + \ Bu özellikler ışığında, Servet-i Fünun döneminin önemli şairlerinden olan Cenab Şahabettin'i işaretlemek gerekir.\ + \ Doğru cevap D şıkkıdır.\n\nSoru: Selime’nin odasında biraz kaldıktan sonra otelden çıktım ( ) kırlara doğru yürüdüm ( )\ + \ Tozlu bir yol ( ) İki yanında fırınlar ( ) kahveler ( ) büyük ambarlar var ( )\ + \ Bu parçada yay ayraçlarla gösterilen yerlere aşağıdaki noktalama işaretlerinden hangisinde\ + \ verilenler getirilmelidir?\nA) (,) (.) (...) (,) (,) (.)\nB) (,) (!) (.) (,) (;) (...)\nC)\ + \ (...) (.) (...) (,) (,) (.)\nD) (,) (.) (.) (,) (,) (.)\nE) (,) (.) (;) (,) (,) (.)\nÇözüm: Adım adım düşünelim.\ + \ Parçada yay ayraçlarla gösterilen yerlere uygun noktalama işaretlerini belirlememiz gerekiyor.\ + \ Parçada yer alan noktalama işaretlerini dikkate alarak, uygun noktalama işaretlerini belirleyelim:\ + \ Selime’nin odasında biraz kaldıktan sonra otelden çıktım (,) kırlara doğru yürüdüm (.)\ + \ Tozlu bir yol (...) İki yanında fırınlar (,) kahveler (,) büyük ambarlar var (.)\ + \ Parçada yer alan noktalama işaretlerine göre, doğru sıralama şu şekildedir: (,) (.) (...) (,) (,) (.)\ + \ Doğru cevap A şıkkıdır.\n\nSoru: HOROZLA İNCİ Bir horoz inci bulur, kuyumcuya gider: “Al, şuna bak, der, pırıl pırıl,\ + \ ne özrü ne kusuru var. Fakat sen bana bir avuç mısır ver, benim işime o yarar.”\ + \ Bir cahile bir kitap miras kalır. Adam kitabı alır, komşusu kitapçıya gider:\ + \ “Bak, ne güzel kitap, der, fakat sen bana beş on kuruş ver, benim işime o yarar.”\ + \ Nâzım Hikmet , La Fontaine’den Masallar Bu fablda; I. Teşhis ve intak sanatlarından yararlanıldığı,\ + \ II. Fablın kahramanlarından birinin hayvan olduğu, III. Fablda zamanın belli olduğu bilgilerinden hangilerine\ + \ ulaşılabilir?\nA) Yalnız I\nB) Yalnız II\nC) I ve II\nD) I ve III\nE) II ve III\nÇözüm: Adım adım düşünelim. + \ Verilen metinde, bir horoz ve bir cahil (insan) arasında bir benzetme yapılmıştır. Bu fabldan hangi bilgilere ulaşılabilir gözden geçirelim:\ + \ I. Teşhis ve intak sanatlarından yararlanıldığı - Metinde, horozun inciyi bulduktan sonra kuyumcuya gidip onun değerini belirlemesi anlatılmaktadır.\ + \ Bu, bir tür değerlendirme ve tanımlama sürecidir. Dolayısıyla, I doğrudur.\ + \ II. Fablın kahramanlarından birinin hayvan olduğu - Metinde, horozun inci bulduğu ve cahilin bir kitap bulduğu anlatılmaktadır.\ + \ Horoz bir hayvandır, dolayısıyla fablın bir hayvan karakterine sahip olduğunu söyleyebiliriz. II doğrudur.\ + \ III. Fablda zamanın belli olduğu - Metinde, zaman belirtilmemiştir. Dolayısıyla, III hakkında bir bilgiye ulaşılamaz.\ + \ Sonuç olarak, I ve II doğru yanıtlardır, ancak III hakkında bir bilgiye ulaşılamaz.\ + \ Doğru cevap D şıkkıdır." +num_fewshot: 0 +dataset_name: Turkish_Language_and_Literature diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/_turkishmmlu_cot_default_yaml b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/_turkishmmlu_cot_default_yaml new file mode 100644 index 0000000000000000000000000000000000000000..03986c163be12ab79c7497f94d6f3625499a7af7 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/turkishmmlu/config_cot/_turkishmmlu_cot_default_yaml @@ -0,0 +1,34 @@ +tag: turkishmmlu_cot +task: null +dataset_path: AYueksel/TurkishMMLU +dataset_name: TurkishMMLU +test_split: test +fewshot_split: dev +output_type: generate_until +doc_to_text: "\n\nSoru: {{ question.strip() }}\nA) {{ choices[0] }}\nB) {{ choices[1] }}\nC) {{ choices[2] }}\nD) {{ choices[3] }}\nE) {{ choices[4] }}\nÇözüm: Adım adım düşünelim." +doc_to_target: "{{ answer }}" +filter_list: + - name: "get-answer" + filter: + - function: "regex" + regex_pattern: "([A-E])(?= şıkkıdır| şıkkı)" + - function: "take_first" + - name: "get-choice" + filter: + - function: "regex" + regex_pattern: "([A-E])" + - function: "take_first" +generation_kwargs: + until: + - "" + do_sample: false + temperature: 0.0 +num_fewshot: 0 +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true +metadata: + version: 0.0 diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/unitxt/__pycache__/task.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/unitxt/__pycache__/task.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eefcc70a695c2a8b05a6270192aa5b84f0de4bc7 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/unitxt/__pycache__/task.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/winogender/__pycache__/utils.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/winogender/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c446aaec53764b368e6c694c1ba3a9a4da01e3ed Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/winogender/__pycache__/utils.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/winogrande/__pycache__/preprocess_winogrande.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/winogrande/__pycache__/preprocess_winogrande.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..135533e4507db887702c3d5809abbc1f8f65a1e8 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lm_eval/tasks/winogrande/__pycache__/preprocess_winogrande.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/ElementInclude.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/ElementInclude.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c2aa56dd7291e3793cd04409cd391415991a3e4 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/ElementInclude.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/__init__.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..465c41f2b2d8f65641b4a1f1fd7efa8fe4487a67 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/__init__.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/_elementpath.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/_elementpath.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..88dd1aa60731941be4737ca944e1b6bc85939f86 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/_elementpath.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/builder.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/builder.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..784031a5f0e4c9e14a632466017f793b08d79aec Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/builder.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/cssselect.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/cssselect.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..86f5a8ffbbefef9860dc17e053133b316fc70952 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/cssselect.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/doctestcompare.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/doctestcompare.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ab90975afffe012716c43162cd488c65e63b7f8f Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/doctestcompare.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/pyclasslookup.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/pyclasslookup.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ab2be366060c69dd7afc0ba2e4568cd076fa3a26 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/pyclasslookup.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/sax.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/sax.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d29aeabb6416fcc779c65b4d67036c9b0bac385 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/sax.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/usedoctest.cpython-311.pyc b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/usedoctest.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..04dfd995852ea588126aefaad5270f96d4180c17 Binary files /dev/null and b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/__pycache__/usedoctest.cpython-311.pyc differ diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/html/ElementSoup.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/html/ElementSoup.py new file mode 100644 index 0000000000000000000000000000000000000000..c35365d0510605c08588775d4e5598586c8f8311 --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/html/ElementSoup.py @@ -0,0 +1,10 @@ +__doc__ = """Legacy interface to the BeautifulSoup HTML parser. +""" + +__all__ = ["parse", "convert_tree"] + +from .soupparser import convert_tree, parse as _parse + +def parse(file, beautifulsoup=None, makeelement=None): + root = _parse(file, beautifulsoup=beautifulsoup, makeelement=makeelement) + return root.getroot() diff --git a/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/html/__init__.py b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/html/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..2cee9f441d896b088bd873aa1ceef12abbb31dda --- /dev/null +++ b/data/conda_envs/evalclaw/lib/python3.11/site-packages/lxml/html/__init__.py @@ -0,0 +1,1927 @@ +# Copyright (c) 2004 Ian Bicking. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# 3. Neither the name of Ian Bicking nor the names of its contributors may +# be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IAN BICKING OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""The ``lxml.html`` tool set for HTML handling. +""" + + +__all__ = [ + 'document_fromstring', 'fragment_fromstring', 'fragments_fromstring', 'fromstring', + 'tostring', 'Element', 'defs', 'open_in_browser', 'submit_form', + 'find_rel_links', 'find_class', 'make_links_absolute', + 'resolve_base_href', 'iterlinks', 'rewrite_links', 'parse'] + + +import copy +import re + +from collections.abc import MutableMapping, MutableSet +from functools import partial +from urllib.parse import urljoin + +from .. import etree +from . import defs +from ._setmixin import SetMixin + + +def __fix_docstring(s): + # TODO: remove and clean up doctests + if not s: + return s + sub = re.compile(r"^(\s*)u'", re.M).sub + return sub(r"\1'", s) + + +XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml" + +_rel_links_xpath = etree.XPath("descendant-or-self::a[@rel]|descendant-or-self::x:a[@rel]", + namespaces={'x':XHTML_NAMESPACE}) +_options_xpath = etree.XPath("descendant-or-self::option|descendant-or-self::x:option", + namespaces={'x':XHTML_NAMESPACE}) +_forms_xpath = etree.XPath("descendant-or-self::form|descendant-or-self::x:form", + namespaces={'x':XHTML_NAMESPACE}) +#_class_xpath = etree.XPath(r"descendant-or-self::*[regexp:match(@class, concat('\b', $class_name, '\b'))]", {'regexp': 'http://exslt.org/regular-expressions'}) +_class_xpath = etree.XPath("descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), concat(' ', $class_name, ' '))]") +_id_xpath = etree.XPath("descendant-or-self::*[@id=$id]") +_collect_string_content = etree.XPath("string()", smart_strings=False) +_iter_css_urls = re.compile(r'url\(('+'["][^"]*["]|'+"['][^']*[']|"+r'[^)]*)\)', re.I).finditer +_iter_css_imports = re.compile(r'@import "(.*?)"').finditer +_label_xpath = etree.XPath("//label[@for=$id]|//x:label[@for=$id]", + namespaces={'x':XHTML_NAMESPACE}) +_archive_re = re.compile(r'[^ ]+') +_parse_meta_refresh_url = re.compile( + r'[^;=]*;\s*(?:url\s*=\s*)?(?P.*)$', re.I).search + + +def _unquote_match(s, pos): + if s[:1] == '"' and s[-1:] == '"' or s[:1] == "'" and s[-1:] == "'": + return s[1:-1], pos+1 + else: + return s,pos + + +def _transform_result(typ, result): + """Convert the result back into the input type. + """ + if issubclass(typ, bytes): + return tostring(result, encoding='utf-8') + elif issubclass(typ, str): + return tostring(result, encoding='unicode') + else: + return result + + +def _nons(tag): + if isinstance(tag, str): + if tag[0] == '{' and tag[1:len(XHTML_NAMESPACE)+1] == XHTML_NAMESPACE: + return tag.split('}')[-1] + return tag + + +class Classes(MutableSet): + """Provides access to an element's class attribute as a set-like collection. + Usage:: + + >>> el = fromstring('') + >>> classes = el.classes # or: classes = Classes(el.attrib) + >>> classes |= ['block', 'paragraph'] + >>> el.get('class') + 'hidden large block paragraph' + >>> classes.toggle('hidden') + False + >>> el.get('class') + 'large block paragraph' + >>> classes -= ('some', 'classes', 'block') + >>> el.get('class') + 'large paragraph' + """ + def __init__(self, attributes): + self._attributes = attributes + self._get_class_value = partial(attributes.get, 'class', '') + + def add(self, value): + """ + Add a class. + + This has no effect if the class is already present. + """ + if not value or re.search(r'\s', value): + raise ValueError("Invalid class name: %r" % value) + classes = self._get_class_value().split() + if value in classes: + return + classes.append(value) + self._attributes['class'] = ' '.join(classes) + + def discard(self, value): + """ + Remove a class if it is currently present. + + If the class is not present, do nothing. + """ + if not value or re.search(r'\s', value): + raise ValueError("Invalid class name: %r" % value) + classes = [name for name in self._get_class_value().split() + if name != value] + if classes: + self._attributes['class'] = ' '.join(classes) + elif 'class' in self._attributes: + del self._attributes['class'] + + def remove(self, value): + """ + Remove a class; it must currently be present. + + If the class is not present, raise a KeyError. + """ + if not value or re.search(r'\s', value): + raise ValueError("Invalid class name: %r" % value) + super().remove(value) + + def __contains__(self, name): + classes = self._get_class_value() + return name in classes and name in classes.split() + + def __iter__(self): + return iter(self._get_class_value().split()) + + def __len__(self): + return len(self._get_class_value().split()) + + # non-standard methods + + def update(self, values): + """ + Add all names from 'values'. + """ + classes = self._get_class_value().split() + extended = False + for value in values: + if value not in classes: + classes.append(value) + extended = True + if extended: + self._attributes['class'] = ' '.join(classes) + + def toggle(self, value): + """ + Add a class name if it isn't there yet, or remove it if it exists. + + Returns true if the class was added (and is now enabled) and + false if it was removed (and is now disabled). + """ + if not value or re.search(r'\s', value): + raise ValueError("Invalid class name: %r" % value) + classes = self._get_class_value().split() + try: + classes.remove(value) + enabled = False + except ValueError: + classes.append(value) + enabled = True + if classes: + self._attributes['class'] = ' '.join(classes) + else: + del self._attributes['class'] + return enabled + + +class HtmlMixin: + + def set(self, key, value=None): + """set(self, key, value=None) + + Sets an element attribute. If no value is provided, or if the value is None, + creates a 'boolean' attribute without value, e.g. "
" + for ``form.set('novalidate')``. + """ + super().set(key, value) + + @property + def classes(self): + """ + A set-like wrapper around the 'class' attribute. + """ + return Classes(self.attrib) + + @classes.setter + def classes(self, classes): + assert isinstance(classes, Classes) # only allow "el.classes |= ..." etc. + value = classes._get_class_value() + if value: + self.set('class', value) + elif self.get('class') is not None: + del self.attrib['class'] + + @property + def base_url(self): + """ + Returns the base URL, given when the page was parsed. + + Use with ``urlparse.urljoin(el.base_url, href)`` to get + absolute URLs. + """ + return self.getroottree().docinfo.URL + + @property + def forms(self): + """ + Return a list of all the forms + """ + return _forms_xpath(self) + + @property + def body(self): + """ + Return the element. Can be called from a child element + to get the document's head. + """ + for element in self.getroottree().iter("body", f"{{{XHTML_NAMESPACE}}}body"): + return element + return None + + @property + def head(self): + """ + Returns the element. Can be called from a child + element to get the document's head. + """ + for element in self.getroottree().iter("head", f"{{{XHTML_NAMESPACE}}}head"): + return element + return None + + @property + def label(self): + """ + Get or set any