mirror of
https://github.com/microsoft/FLAML.git
synced 2026-02-15 13:19:16 +08:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3de0dc667e | ||
|
|
6840dc2b09 | ||
|
|
1a9fa3ac23 | ||
|
|
325baa40a5 | ||
|
|
550d1cfe9b | ||
|
|
249f0f1708 | ||
|
|
b645da3ea7 | ||
|
|
0415638dd1 | ||
|
|
6b93c2e394 | ||
|
|
a93bf39720 | ||
|
|
dc8060a21b | ||
|
|
30db685cee | ||
|
|
fda9fa0103 | ||
|
|
830ec4541c | ||
|
|
46162578f8 | ||
|
|
8658e51182 | ||
|
|
868e7dd1ca | ||
|
|
4886cb5689 | ||
|
|
599731cb22 | ||
|
|
0cb79dfdff | ||
|
|
f70df312f4 | ||
|
|
93b9e09166 | ||
|
|
3c6e191044 | ||
|
|
5f9b514be7 |
3
.github/workflows/deploy-website.yml
vendored
3
.github/workflows/deploy-website.yml
vendored
@@ -17,6 +17,9 @@ on:
|
||||
merge_group:
|
||||
types: [checks_requested]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
if: github.event_name != 'push'
|
||||
|
||||
2
.github/workflows/openai.yml
vendored
2
.github/workflows/openai.yml
vendored
@@ -13,6 +13,8 @@ on:
|
||||
- 'notebook/autogen_chatgpt_gpt4.ipynb'
|
||||
- '.github/workflows/openai.yml'
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
|
||||
1
.github/workflows/pre-commit.yml
vendored
1
.github/workflows/pre-commit.yml
vendored
@@ -10,6 +10,7 @@ defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
permissions: {}
|
||||
jobs:
|
||||
|
||||
pre-commit-check:
|
||||
|
||||
5
.github/workflows/python-package.yml
vendored
5
.github/workflows/python-package.yml
vendored
@@ -17,6 +17,7 @@ on:
|
||||
merge_group:
|
||||
types: [checks_requested]
|
||||
|
||||
permissions: {}
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
@@ -64,10 +65,12 @@ jobs:
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
pip install "ray[tune]<2.5.0"
|
||||
- name: If mac, install ray
|
||||
- name: If mac, install ray and xgboost 1
|
||||
if: matrix.os == 'macOS-latest'
|
||||
run: |
|
||||
pip install -e .[ray]
|
||||
# use macOS to test xgboost 1, but macOS also supports xgboost 2
|
||||
pip install "xgboost<2"
|
||||
- name: If linux or mac, install prophet on python < 3.9
|
||||
if: (matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest') && matrix.python-version != '3.9' && matrix.python-version != '3.10'
|
||||
run: |
|
||||
|
||||
12
README.md
12
README.md
@@ -14,11 +14,13 @@
|
||||
<br>
|
||||
</p>
|
||||
|
||||
:fire: The automated multi-agent chat framework in [autogen](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen) is in preview from v2.0.0.
|
||||
:fire: Heads-up: We have migrated [AutoGen](https://microsoft.github.io/autogen/) into a dedicated [github repository](https://github.com/microsoft/autogen). Alongside this move, we have also launched a dedicated [Discord](https://discord.gg/pAbnFJrkgZ) server and a [website](https://microsoft.github.io/autogen/) for comprehensive documentation.
|
||||
|
||||
:fire: The automated multi-agent chat framework in [AutoGen](https://microsoft.github.io/autogen/) is in preview from v2.0.0.
|
||||
|
||||
:fire: FLAML is highlighted in OpenAI's [cookbook](https://github.com/openai/openai-cookbook#related-resources-from-around-the-web).
|
||||
|
||||
:fire: [autogen](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen) is released with support for ChatGPT and GPT-4, based on [Cost-Effective Hyperparameter Optimization for Large Language Model Generation Inference](https://arxiv.org/abs/2303.04673).
|
||||
:fire: [autogen](https://microsoft.github.io/autogen/) is released with support for ChatGPT and GPT-4, based on [Cost-Effective Hyperparameter Optimization for Large Language Model Generation Inference](https://arxiv.org/abs/2303.04673).
|
||||
|
||||
:fire: FLAML supports Code-First AutoML & Tuning – Private Preview in [Microsoft Fabric Data Science](https://learn.microsoft.com/en-us/fabric/data-science/).
|
||||
|
||||
@@ -32,7 +34,7 @@ and optimizes their performance.
|
||||
* For common machine learning tasks like classification and regression, it quickly finds quality models for user-provided data with low computational resources. It is easy to customize or extend. Users can find their desired customizability from a smooth range.
|
||||
* It supports fast and economical automatic tuning (e.g., inference hyperparameters for foundation models, configurations in MLOps/LMOps workflows, pipelines, mathematical/statistical models, algorithms, computing experiments, software configurations), capable of handling large search space with heterogeneous evaluation cost and complex constraints/guidance/early stopping.
|
||||
|
||||
FLAML is powered by a series of [research studies](/docs/Research) from Microsoft Research and collaborators such as Penn State University, Stevens Institute of Technology, University of Washington, and University of Waterloo.
|
||||
FLAML is powered by a series of [research studies](https://microsoft.github.io/FLAML/docs/Research/) from Microsoft Research and collaborators such as Penn State University, Stevens Institute of Technology, University of Washington, and University of Waterloo.
|
||||
|
||||
FLAML has a .NET implementation in [ML.NET](http://dot.net/ml), an open-source, cross-platform machine learning framework for .NET.
|
||||
|
||||
@@ -44,7 +46,7 @@ FLAML requires **Python version >= 3.8**. It can be installed from pip:
|
||||
pip install flaml
|
||||
```
|
||||
|
||||
Minimal dependencies are installed without extra options. You can install extra options based on the feature you need. For example, use the following to install the dependencies needed by the [`autogen`](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen) package.
|
||||
Minimal dependencies are installed without extra options. You can install extra options based on the feature you need. For example, use the following to install the dependencies needed by the [`autogen`](https://microsoft.github.io/autogen/) package.
|
||||
```bash
|
||||
pip install "flaml[autogen]"
|
||||
```
|
||||
@@ -54,7 +56,7 @@ Each of the [`notebook examples`](https://github.com/microsoft/FLAML/tree/main/n
|
||||
|
||||
## Quickstart
|
||||
|
||||
* (New) The [autogen](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen) package enables the next-gen GPT-X applications with a generic multi-agent conversation framework.
|
||||
* (New) The [autogen](https://microsoft.github.io/autogen/) package enables the next-gen GPT-X applications with a generic multi-agent conversation framework.
|
||||
It offers customizable and conversable agents which integrate LLMs, tools and human.
|
||||
By automating chat among multiple capable agents, one can easily make them collectively perform tasks autonomously or with human feedback, including tasks that require using tools via code. For example,
|
||||
```python
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import logging
|
||||
from flaml.automl import AutoML, logger_formatter
|
||||
from flaml.tune.searcher import CFO, BlendSearch, FLOW2, BlendSearchTuner, RandomSearch
|
||||
from flaml.onlineml.autovw import AutoVW
|
||||
from flaml.version import __version__
|
||||
|
||||
from flaml.automl import AutoML, logger_formatter
|
||||
from flaml.onlineml.autovw import AutoVW
|
||||
from flaml.tune.searcher import CFO, FLOW2, BlendSearch, BlendSearchTuner, RandomSearch
|
||||
from flaml.version import __version__
|
||||
|
||||
# Set the root logger.
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from .oai import *
|
||||
from .agentchat import *
|
||||
from .code_utils import DEFAULT_MODEL, FAST_MODEL
|
||||
from .oai import *
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from .agent import Agent
|
||||
from .responsive_agent import ResponsiveAgent
|
||||
from .assistant_agent import AssistantAgent
|
||||
from .user_proxy_agent import UserProxyAgent
|
||||
from .conversable_agent import ConversableAgent
|
||||
from .groupchat import GroupChat, GroupChatManager
|
||||
from .user_proxy_agent import UserProxyAgent
|
||||
|
||||
__all__ = [
|
||||
"Agent",
|
||||
"ResponsiveAgent",
|
||||
"ConversableAgent",
|
||||
"AssistantAgent",
|
||||
"UserProxyAgent",
|
||||
"GroupChat",
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from .responsive_agent import ResponsiveAgent
|
||||
from typing import Callable, Dict, Optional, Union
|
||||
|
||||
from .conversable_agent import ConversableAgent
|
||||
|
||||
class AssistantAgent(ResponsiveAgent):
|
||||
|
||||
class AssistantAgent(ConversableAgent):
|
||||
"""(In preview) Assistant agent, designed to solve a task with LLM.
|
||||
|
||||
AssistantAgent is a subclass of ResponsiveAgent configured with a default system message.
|
||||
AssistantAgent is a subclass of ConversableAgent configured with a default system message.
|
||||
The default system message is designed to solve a task with LLM,
|
||||
including suggesting python code blocks and debugging.
|
||||
`human_input_mode` is default to "NEVER"
|
||||
@@ -52,7 +53,7 @@ Reply "TERMINATE" in the end when everything is done.
|
||||
default to None (no limit provided, class attribute MAX_CONSECUTIVE_AUTO_REPLY will be used as the limit in this case).
|
||||
The limit only plays a role when human_input_mode is not "ALWAYS".
|
||||
**kwargs (dict): Please refer to other kwargs in
|
||||
[ResponsiveAgent](responsive_agent#__init__).
|
||||
[ConversableAgent](conversable_agent#__init__).
|
||||
"""
|
||||
super().__init__(
|
||||
name,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import re
|
||||
import os
|
||||
from pydantic import BaseModel, Extra, root_validator
|
||||
from typing import Any, Callable, Dict, List, Optional, Union
|
||||
import re
|
||||
from time import sleep
|
||||
from typing import Any, Callable, Dict, List, Optional, Union
|
||||
|
||||
from pydantic import BaseModel, Extra, root_validator
|
||||
|
||||
from flaml.autogen.agentchat import Agent, UserProxyAgent
|
||||
from flaml.autogen.code_utils import UNKNOWN, extract_code, execute_code, infer_lang
|
||||
from flaml.autogen.code_utils import UNKNOWN, execute_code, extract_code, infer_lang
|
||||
from flaml.autogen.math_utils import get_answer
|
||||
|
||||
|
||||
PROMPTS = {
|
||||
# default
|
||||
"default": """Let's use Python to solve a math problem.
|
||||
@@ -165,7 +165,7 @@ class MathUserProxyAgent(UserProxyAgent):
|
||||
default_auto_reply=default_auto_reply,
|
||||
**kwargs,
|
||||
)
|
||||
self.register_auto_reply([Agent, None], MathUserProxyAgent._generate_math_reply, 1)
|
||||
self.register_reply([Agent, None], MathUserProxyAgent._generate_math_reply, 1)
|
||||
# fixed var
|
||||
self._max_invalid_q_per_step = max_invalid_q_per_step
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from flaml.autogen.agentchat.agent import Agent
|
||||
from flaml.autogen.agentchat.assistant_agent import AssistantAgent
|
||||
from typing import Callable, Dict, Optional, Union, List, Tuple, Any
|
||||
|
||||
|
||||
class RetrieveAssistantAgent(AssistantAgent):
|
||||
@@ -16,7 +17,7 @@ class RetrieveAssistantAgent(AssistantAgent):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.register_auto_reply(Agent, RetrieveAssistantAgent._generate_retrieve_assistant_reply)
|
||||
self.register_reply(Agent, RetrieveAssistantAgent._generate_retrieve_assistant_reply)
|
||||
|
||||
def _generate_retrieve_assistant_reply(
|
||||
self,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import chromadb
|
||||
from flaml.autogen.agentchat.agent import Agent
|
||||
from flaml.autogen.agentchat import UserProxyAgent
|
||||
from flaml.autogen.retrieve_utils import create_vector_db_from_dir, query_vector_db, num_tokens_from_text
|
||||
from flaml.autogen.code_utils import extract_code
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from typing import Callable, Dict, Optional, Union, List, Tuple, Any
|
||||
import chromadb
|
||||
from IPython import get_ipython
|
||||
|
||||
from flaml.autogen.agentchat import UserProxyAgent
|
||||
from flaml.autogen.agentchat.agent import Agent
|
||||
from flaml.autogen.code_utils import extract_code
|
||||
from flaml.autogen.retrieve_utils import create_vector_db_from_dir, num_tokens_from_text, query_vector_db
|
||||
|
||||
try:
|
||||
from termcolor import colored
|
||||
except ImportError:
|
||||
@@ -148,7 +149,7 @@ class RetrieveUserProxyAgent(UserProxyAgent):
|
||||
self._ipython = get_ipython()
|
||||
self._doc_idx = -1 # the index of the current used doc
|
||||
self._results = {} # the results of the current query
|
||||
self.register_auto_reply(Agent, RetrieveUserProxyAgent._generate_retrieve_user_reply)
|
||||
self.register_reply(Agent, RetrieveUserProxyAgent._generate_retrieve_user_reply)
|
||||
|
||||
@staticmethod
|
||||
def get_max_tokens(model="gpt-3.5-turbo"):
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import asyncio
|
||||
from collections import defaultdict
|
||||
import copy
|
||||
import json
|
||||
from collections import defaultdict
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||
|
||||
from flaml.autogen import oai
|
||||
from .agent import Agent
|
||||
from flaml.autogen.code_utils import (
|
||||
DEFAULT_MODEL,
|
||||
UNKNOWN,
|
||||
@@ -13,6 +13,8 @@ from flaml.autogen.code_utils import (
|
||||
infer_lang,
|
||||
)
|
||||
|
||||
from .agent import Agent
|
||||
|
||||
try:
|
||||
from termcolor import colored
|
||||
except ImportError:
|
||||
@@ -21,11 +23,11 @@ except ImportError:
|
||||
return x
|
||||
|
||||
|
||||
class ResponsiveAgent(Agent):
|
||||
"""(Experimental) A class for generic responsive agents which can be configured as assistant or user proxy.
|
||||
class ConversableAgent(Agent):
|
||||
"""(In preview) A class for generic conversable agents which can be configured as assistant or user proxy.
|
||||
|
||||
After receiving each message, the agent will send a reply to the sender unless the msg is a termination msg.
|
||||
For example, AssistantAgent and UserProxyAgent are subclasses of ResponsiveAgent,
|
||||
For example, AssistantAgent and UserProxyAgent are subclasses of this class,
|
||||
configured with different default settings.
|
||||
|
||||
To modify auto reply, override `generate_reply` method.
|
||||
@@ -119,12 +121,12 @@ class ResponsiveAgent(Agent):
|
||||
self._default_auto_reply = default_auto_reply
|
||||
self._reply_func_list = []
|
||||
self.reply_at_receive = defaultdict(bool)
|
||||
self.register_auto_reply([Agent, None], ResponsiveAgent.generate_oai_reply)
|
||||
self.register_auto_reply([Agent, None], ResponsiveAgent.generate_code_execution_reply)
|
||||
self.register_auto_reply([Agent, None], ResponsiveAgent.generate_function_call_reply)
|
||||
self.register_auto_reply([Agent, None], ResponsiveAgent.check_termination_and_human_reply)
|
||||
self.register_reply([Agent, None], ConversableAgent.generate_oai_reply)
|
||||
self.register_reply([Agent, None], ConversableAgent.generate_code_execution_reply)
|
||||
self.register_reply([Agent, None], ConversableAgent.generate_function_call_reply)
|
||||
self.register_reply([Agent, None], ConversableAgent.check_termination_and_human_reply)
|
||||
|
||||
def register_auto_reply(
|
||||
def register_reply(
|
||||
self,
|
||||
trigger: Union[Type[Agent], str, Agent, Callable[[Agent], bool], List],
|
||||
reply_func: Callable,
|
||||
@@ -151,7 +153,7 @@ class ResponsiveAgent(Agent):
|
||||
The function takes a recipient agent, a list of messages, a sender agent and a config as input and returns a reply message.
|
||||
```python
|
||||
def reply_func(
|
||||
recipient: ResponsiveAgent,
|
||||
recipient: ConversableAgent,
|
||||
messages: Optional[List[Dict]] = None,
|
||||
sender: Optional[Agent] = None,
|
||||
config: Optional[Any] = None,
|
||||
@@ -499,7 +501,7 @@ class ResponsiveAgent(Agent):
|
||||
|
||||
def initiate_chat(
|
||||
self,
|
||||
recipient: "ResponsiveAgent",
|
||||
recipient: "ConversableAgent",
|
||||
clear_history: Optional[bool] = True,
|
||||
silent: Optional[bool] = False,
|
||||
**context,
|
||||
@@ -522,7 +524,7 @@ class ResponsiveAgent(Agent):
|
||||
|
||||
async def a_initiate_chat(
|
||||
self,
|
||||
recipient: "ResponsiveAgent",
|
||||
recipient: "ConversableAgent",
|
||||
clear_history: Optional[bool] = True,
|
||||
silent: Optional[bool] = False,
|
||||
**context,
|
||||
@@ -611,7 +613,7 @@ class ResponsiveAgent(Agent):
|
||||
if messages is None:
|
||||
messages = self._oai_messages[sender]
|
||||
last_n_messages = code_execution_config.pop("last_n_messages", 1)
|
||||
for i in range(last_n_messages):
|
||||
for i in range(min(len(messages), last_n_messages)):
|
||||
message = messages[-(i + 1)]
|
||||
code_blocks = extract_code(message["content"])
|
||||
if len(code_blocks) == 1 and code_blocks[0][0] == UNKNOWN:
|
||||
@@ -1,8 +1,9 @@
|
||||
from dataclasses import dataclass
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from .agent import Agent
|
||||
from .responsive_agent import ResponsiveAgent
|
||||
from .conversable_agent import ConversableAgent
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -12,6 +13,7 @@ class GroupChat:
|
||||
agents: List[Agent]
|
||||
messages: List[Dict]
|
||||
max_round: int = 10
|
||||
admin_name: str = "Admin" # the name of the admin agent
|
||||
|
||||
@property
|
||||
def agent_names(self) -> List[str]:
|
||||
@@ -38,7 +40,7 @@ class GroupChat:
|
||||
Read the following conversation.
|
||||
Then select the next role from {self.agent_names} to play. Only return the role."""
|
||||
|
||||
def select_speaker(self, last_speaker: Agent, selector: ResponsiveAgent):
|
||||
def select_speaker(self, last_speaker: Agent, selector: ConversableAgent):
|
||||
"""Select the next speaker."""
|
||||
selector.update_system_message(self.select_speaker_msg())
|
||||
final, name = selector.generate_oai_reply(
|
||||
@@ -62,7 +64,7 @@ Then select the next role from {self.agent_names} to play. Only return the role.
|
||||
return "\n".join([f"{agent.name}: {agent.system_message}" for agent in self.agents])
|
||||
|
||||
|
||||
class GroupChatManager(ResponsiveAgent):
|
||||
class GroupChatManager(ConversableAgent):
|
||||
"""(In preview) A chat manager agent that can manage a group chat of multiple agents."""
|
||||
|
||||
def __init__(
|
||||
@@ -83,7 +85,7 @@ class GroupChatManager(ResponsiveAgent):
|
||||
system_message=system_message,
|
||||
**kwargs,
|
||||
)
|
||||
self.register_auto_reply(Agent, GroupChatManager.run_chat, config=groupchat, reset_config=GroupChat.reset)
|
||||
self.register_reply(Agent, GroupChatManager.run_chat, config=groupchat, reset_config=GroupChat.reset)
|
||||
# self._random = random.Random(seed)
|
||||
|
||||
def run_chat(
|
||||
@@ -97,21 +99,36 @@ class GroupChatManager(ResponsiveAgent):
|
||||
messages = self._oai_messages[sender]
|
||||
message = messages[-1]
|
||||
speaker = sender
|
||||
for i in range(config.max_round):
|
||||
groupchat = config
|
||||
for i in range(groupchat.max_round):
|
||||
# set the name to speaker's name if the role is not function
|
||||
if message["role"] != "function":
|
||||
message["name"] = speaker.name
|
||||
config.messages.append(message)
|
||||
groupchat.messages.append(message)
|
||||
# broadcast the message to all agents except the speaker
|
||||
for agent in config.agents:
|
||||
for agent in groupchat.agents:
|
||||
if agent != speaker:
|
||||
self.send(message, agent, request_reply=False, silent=True)
|
||||
if i != config.max_round - 1:
|
||||
# speaker selection msg from an agent
|
||||
speaker = config.select_speaker(speaker, self)
|
||||
if i == groupchat.max_round - 1:
|
||||
# the last round
|
||||
break
|
||||
try:
|
||||
# select the next speaker
|
||||
speaker = groupchat.select_speaker(speaker, self)
|
||||
# let the speaker speak
|
||||
reply = speaker.generate_reply(sender=self)
|
||||
if reply is None:
|
||||
break
|
||||
speaker.send(reply, self, request_reply=False)
|
||||
message = self.last_message(speaker)
|
||||
except KeyboardInterrupt:
|
||||
# let the admin agent speak if interrupted
|
||||
if groupchat.admin_name in groupchat.agent_names:
|
||||
# admin agent is one of the participants
|
||||
speaker = groupchat.agent_by_name(groupchat.admin_name)
|
||||
reply = speaker.generate_reply(sender=self)
|
||||
else:
|
||||
# admin agent is not found in the participants
|
||||
raise
|
||||
if reply is None:
|
||||
break
|
||||
# The speaker sends the message without requesting a reply
|
||||
speaker.send(reply, self, request_reply=False)
|
||||
message = self.last_message(speaker)
|
||||
return True, None
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
from .responsive_agent import ResponsiveAgent
|
||||
from typing import Callable, Dict, Optional, Union
|
||||
|
||||
from .conversable_agent import ConversableAgent
|
||||
|
||||
class UserProxyAgent(ResponsiveAgent):
|
||||
|
||||
class UserProxyAgent(ConversableAgent):
|
||||
"""(In preview) A proxy agent for the user, that can execute code and provide feedback to the other agents.
|
||||
|
||||
UserProxyAgent is a subclass of ResponsiveAgent configured with `human_input_mode` to ALWAYS
|
||||
UserProxyAgent is a subclass of ConversableAgent configured with `human_input_mode` to ALWAYS
|
||||
and `llm_config` to False. By default, the agent will prompt for human input every time a message is received.
|
||||
Code execution is enabled by default. LLM-based auto reply is disabled by default.
|
||||
To modify auto reply, register a method with (`register_auto_reply`)[responsive_agent#register_auto_reply].
|
||||
To modify auto reply, register a method with (`register_reply`)[conversable_agent#register_reply].
|
||||
To modify the way to get human input, override `get_human_input` method.
|
||||
To modify the way to execute code blocks, single code block, or function call, override `execute_code_blocks`,
|
||||
`run_code`, and `execute_function` methods respectively.
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import pathlib
|
||||
from typing import List, Dict, Tuple, Optional, Union, Callable
|
||||
import re
|
||||
import time
|
||||
from hashlib import md5
|
||||
import logging
|
||||
from typing import Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from flaml.autogen import oai
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from typing import Optional
|
||||
from flaml.autogen import oai, DEFAULT_MODEL
|
||||
|
||||
from flaml.autogen import DEFAULT_MODEL, oai
|
||||
|
||||
_MATH_PROMPT = "{problem} Solve the problem carefully. Simplify your answer as much as possible. Put the final answer in \\boxed{{}}."
|
||||
_MATH_CONFIG = {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from flaml.autogen.oai.completion import Completion, ChatCompletion
|
||||
from flaml.autogen.oai.completion import ChatCompletion, Completion
|
||||
from flaml.autogen.oai.openai_utils import (
|
||||
get_config_list,
|
||||
config_list_from_json,
|
||||
config_list_from_models,
|
||||
config_list_gpt4_gpt35,
|
||||
config_list_openai_aoai,
|
||||
config_list_from_models,
|
||||
config_list_from_json,
|
||||
get_config_list,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
|
||||
@@ -1,28 +1,31 @@
|
||||
from time import sleep
|
||||
import logging
|
||||
import time
|
||||
from typing import List, Optional, Dict, Callable, Union
|
||||
import sys
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
from time import sleep
|
||||
from typing import Callable, Dict, List, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
from flaml import tune, BlendSearch
|
||||
from flaml.tune.space import is_constant
|
||||
|
||||
from flaml import BlendSearch, tune
|
||||
from flaml.automl.logger import logger_formatter
|
||||
from flaml.tune.space import is_constant
|
||||
|
||||
from .openai_utils import get_key
|
||||
|
||||
try:
|
||||
import openai
|
||||
from openai.error import (
|
||||
ServiceUnavailableError,
|
||||
RateLimitError,
|
||||
APIError,
|
||||
InvalidRequestError,
|
||||
APIConnectionError,
|
||||
Timeout,
|
||||
AuthenticationError,
|
||||
)
|
||||
from openai import Completion as openai_Completion
|
||||
import diskcache
|
||||
import openai
|
||||
from openai import Completion as openai_Completion
|
||||
from openai.error import (
|
||||
APIConnectionError,
|
||||
APIError,
|
||||
AuthenticationError,
|
||||
InvalidRequestError,
|
||||
RateLimitError,
|
||||
ServiceUnavailableError,
|
||||
Timeout,
|
||||
)
|
||||
|
||||
ERROR = None
|
||||
except ImportError:
|
||||
@@ -48,6 +51,7 @@ class Completion(openai_Completion):
|
||||
"gpt-3.5-turbo-0301", # deprecate in Sep
|
||||
"gpt-3.5-turbo-0613",
|
||||
"gpt-3.5-turbo-16k",
|
||||
"gpt-3.5-turbo-16k-0613",
|
||||
"gpt-35-turbo",
|
||||
"gpt-4",
|
||||
"gpt-4-32k",
|
||||
@@ -70,6 +74,7 @@ class Completion(openai_Completion):
|
||||
"gpt-3.5-turbo-0301": (0.0015, 0.002), # deprecate in Sep
|
||||
"gpt-3.5-turbo-0613": (0.0015, 0.002),
|
||||
"gpt-3.5-turbo-16k": (0.003, 0.004),
|
||||
"gpt-3.5-turbo-16k-0613": (0.003, 0.004),
|
||||
"gpt-35-turbo": 0.002,
|
||||
"gpt-4": (0.03, 0.06),
|
||||
"gpt-4-32k": (0.06, 0.12),
|
||||
@@ -695,7 +700,7 @@ class Completion(openai_Completion):
|
||||
E.g., `prompt="Complete the following sentence: {prefix}, context={"prefix": "Today I feel"}`.
|
||||
The actual prompt will be:
|
||||
"Complete the following sentence: Today I feel".
|
||||
More examples can be found at [templating](/docs/Use-Cases/Autogen#templating).
|
||||
More examples can be found at [templating](https://microsoft.github.io/autogen/docs/Use-Cases/enhanced_inference#templating).
|
||||
use_cache (bool, Optional): Whether to use cached responses.
|
||||
config_list (List, Optional): List of configurations for the completion to try.
|
||||
The first one that does not raise an error will be used.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import json
|
||||
from typing import List, Optional, Dict, Set, Union
|
||||
import logging
|
||||
import os
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
|
||||
NON_CACHE_KEY = ["api_key", "api_base", "api_type", "api_version"]
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
from typing import List, Union, Dict, Tuple
|
||||
import os
|
||||
import requests
|
||||
from urllib.parse import urlparse
|
||||
import glob
|
||||
import tiktoken
|
||||
import chromadb
|
||||
from chromadb.api import API
|
||||
import chromadb.utils.embedding_functions as ef
|
||||
import logging
|
||||
import os
|
||||
from typing import Dict, List, Tuple, Union
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import chromadb
|
||||
import chromadb.utils.embedding_functions as ef
|
||||
import requests
|
||||
import tiktoken
|
||||
from chromadb.api import API
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
TEXT_FORMATS = ["txt", "json", "csv", "tsv", "md", "html", "htm", "rtf", "rst", "jsonl", "log", "xml", "yaml", "yml"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from flaml.automl.automl import AutoML, size
|
||||
from flaml.automl.logger import logger_formatter
|
||||
from flaml.automl.state import SearchState, AutoMLState
|
||||
from flaml.automl.state import AutoMLState, SearchState
|
||||
|
||||
__all__ = ["AutoML", "AutoMLState", "SearchState", "logger_formatter", "size"]
|
||||
|
||||
@@ -3,40 +3,41 @@
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
from __future__ import annotations
|
||||
import time
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from typing import Callable, List, Union, Optional
|
||||
import time
|
||||
from functools import partial
|
||||
from typing import Callable, List, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
import logging
|
||||
import json
|
||||
|
||||
from flaml.automl.state import SearchState, AutoMLState
|
||||
from flaml import tune
|
||||
from flaml.automl.logger import logger, logger_formatter
|
||||
from flaml.automl.ml import train_estimator
|
||||
|
||||
from flaml.automl.time_series import TimeSeriesDataset
|
||||
from flaml.config import (
|
||||
MIN_SAMPLE_TRAIN,
|
||||
MEM_THRES,
|
||||
RANDOM_SEED,
|
||||
SMALL_LARGE_THRES,
|
||||
CV_HOLDOUT_THRESHOLD,
|
||||
SPLIT_RATIO,
|
||||
N_SPLITS,
|
||||
SAMPLE_MULTIPLY_FACTOR,
|
||||
)
|
||||
from flaml.automl.spark import DataFrame, Series, psDataFrame, psSeries
|
||||
from flaml.automl.state import AutoMLState, SearchState
|
||||
from flaml.automl.task.factory import task_factory
|
||||
|
||||
# TODO check to see when we can remove these
|
||||
from flaml.automl.task.task import CLASSIFICATION, Task
|
||||
from flaml.automl.task.factory import task_factory
|
||||
from flaml import tune
|
||||
from flaml.automl.logger import logger, logger_formatter
|
||||
from flaml.automl.time_series import TimeSeriesDataset
|
||||
from flaml.automl.training_log import training_log_reader, training_log_writer
|
||||
from flaml.config import (
|
||||
CV_HOLDOUT_THRESHOLD,
|
||||
MEM_THRES,
|
||||
MIN_SAMPLE_TRAIN,
|
||||
N_SPLITS,
|
||||
RANDOM_SEED,
|
||||
SAMPLE_MULTIPLY_FACTOR,
|
||||
SMALL_LARGE_THRES,
|
||||
SPLIT_RATIO,
|
||||
)
|
||||
from flaml.default import suggest_learner
|
||||
from flaml.version import __version__ as flaml_version
|
||||
from flaml.automl.spark import psDataFrame, psSeries, DataFrame, Series
|
||||
from flaml.tune.spark.utils import check_spark, get_broadcast_data
|
||||
from flaml.version import __version__ as flaml_version
|
||||
|
||||
ERROR = (
|
||||
DataFrame is None and ImportError("please install flaml[automl] option to use the flaml.automl package.") or None
|
||||
@@ -246,7 +247,7 @@ class AutoML(BaseEstimator):
|
||||
search is considered to converge.
|
||||
force_cancel: boolean, default=False | Whether to forcely cancel Spark jobs if the
|
||||
search time exceeded the time budget.
|
||||
append_log: boolean, default=False | Whetehr to directly append the log
|
||||
append_log: boolean, default=False | Whether to directly append the log
|
||||
records to the input log file if it exists.
|
||||
auto_augment: boolean, default=True | Whether to automatically
|
||||
augment rare classes.
|
||||
@@ -476,12 +477,12 @@ class AutoML(BaseEstimator):
|
||||
|
||||
@property
|
||||
def feature_transformer(self):
|
||||
"""Returns AutoML Transformer"""
|
||||
"""Returns feature transformer which is used to preprocess data before applying training or inference."""
|
||||
return getattr(self, "_transformer", None)
|
||||
|
||||
@property
|
||||
def label_transformer(self):
|
||||
"""Returns AutoML label transformer"""
|
||||
"""Returns label transformer which is used to preprocess labels before scoring, and inverse transform labels after inference."""
|
||||
return getattr(self, "_label_transformer", None)
|
||||
|
||||
@property
|
||||
@@ -606,7 +607,7 @@ class AutoML(BaseEstimator):
|
||||
|
||||
Args:
|
||||
learner_name: A string of the learner's name.
|
||||
learner_class: A subclass of flaml.model.BaseEstimator.
|
||||
learner_class: A subclass of flaml.automl.model.BaseEstimator.
|
||||
"""
|
||||
self._state.learner_classes[learner_name] = learner_class
|
||||
|
||||
@@ -1381,7 +1382,7 @@ class AutoML(BaseEstimator):
|
||||
early_stop: boolean, default=False | Whether to stop early if the
|
||||
search is considered to converge.
|
||||
force_cancel: boolean, default=False | Whether to forcely cancel the PySpark job if overtime.
|
||||
append_log: boolean, default=False | Whetehr to directly append the log
|
||||
append_log: boolean, default=False | Whether to directly append the log
|
||||
records to the input log file if it exists.
|
||||
auto_augment: boolean, default=True | Whether to automatically
|
||||
augment rare classes.
|
||||
@@ -2647,7 +2648,7 @@ class AutoML(BaseEstimator):
|
||||
if self._estimator_index == len(estimator_list):
|
||||
self._estimator_index = 0
|
||||
return estimator_list[self._estimator_index]
|
||||
min_estimated_cost, selected = np.Inf, None
|
||||
min_estimated_cost, selected = np.inf, None
|
||||
inv = []
|
||||
untried_exists = False
|
||||
for i, estimator in enumerate(estimator_list):
|
||||
|
||||
1
flaml/automl/contrib/__init__.py
Normal file
1
flaml/automl/contrib/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .histgb import HistGradientBoostingEstimator
|
||||
75
flaml/automl/contrib/histgb.py
Normal file
75
flaml/automl/contrib/histgb.py
Normal file
@@ -0,0 +1,75 @@
|
||||
try:
|
||||
from sklearn.ensemble import HistGradientBoostingClassifier, HistGradientBoostingRegressor
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from flaml import tune
|
||||
from flaml.automl.model import SKLearnEstimator
|
||||
from flaml.automl.task import Task
|
||||
|
||||
|
||||
class HistGradientBoostingEstimator(SKLearnEstimator):
|
||||
"""The class for tuning Histogram Gradient Boosting."""
|
||||
|
||||
ITER_HP = "max_iter"
|
||||
HAS_CALLBACK = False
|
||||
DEFAULT_ITER = 100
|
||||
|
||||
@classmethod
|
||||
def search_space(cls, data_size: int, task, **params) -> dict:
|
||||
upper = max(5, min(32768, int(data_size[0]))) # upper must be larger than lower
|
||||
return {
|
||||
"n_estimators": {
|
||||
"domain": tune.lograndint(lower=4, upper=upper),
|
||||
"init_value": 4,
|
||||
"low_cost_init_value": 4,
|
||||
},
|
||||
"max_leaves": {
|
||||
"domain": tune.lograndint(lower=4, upper=upper),
|
||||
"init_value": 4,
|
||||
"low_cost_init_value": 4,
|
||||
},
|
||||
"min_samples_leaf": {
|
||||
"domain": tune.lograndint(lower=2, upper=2**7 + 1),
|
||||
"init_value": 20,
|
||||
},
|
||||
"learning_rate": {
|
||||
"domain": tune.loguniform(lower=1 / 1024, upper=1.0),
|
||||
"init_value": 0.1,
|
||||
},
|
||||
"log_max_bin": { # log transformed with base 2, <= 256
|
||||
"domain": tune.lograndint(lower=3, upper=9),
|
||||
"init_value": 8,
|
||||
},
|
||||
"l2_regularization": {
|
||||
"domain": tune.loguniform(lower=1 / 1024, upper=1024),
|
||||
"init_value": 1.0,
|
||||
},
|
||||
}
|
||||
|
||||
def config2params(self, config: dict) -> dict:
|
||||
params = super().config2params(config)
|
||||
if "log_max_bin" in params:
|
||||
params["max_bins"] = (1 << params.pop("log_max_bin")) - 1
|
||||
if "max_leaves" in params:
|
||||
params["max_leaf_nodes"] = params.get("max_leaf_nodes", params.pop("max_leaves"))
|
||||
if "n_estimators" in params:
|
||||
params["max_iter"] = params.get("max_iter", params.pop("n_estimators"))
|
||||
if "random_state" not in params:
|
||||
params["random_state"] = 24092023
|
||||
if "n_jobs" in params:
|
||||
params.pop("n_jobs")
|
||||
return params
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
task: Task,
|
||||
**config,
|
||||
):
|
||||
super().__init__(task, **config)
|
||||
self.params["verbose"] = 0
|
||||
|
||||
if self._task.is_classification():
|
||||
self.estimator_class = HistGradientBoostingClassifier
|
||||
else:
|
||||
self.estimator_class = HistGradientBoostingRegressor
|
||||
@@ -2,15 +2,17 @@
|
||||
# * Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
import numpy as np
|
||||
import os
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Union
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.automl.spark import DataFrame, Series, pd, ps, psDataFrame, psSeries
|
||||
from flaml.automl.training_log import training_log_reader
|
||||
from flaml.automl.spark import ps, psDataFrame, psSeries, DataFrame, Series, pd
|
||||
|
||||
try:
|
||||
from scipy.sparse import vstack, issparse
|
||||
from scipy.sparse import issparse, vstack
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -41,8 +43,9 @@ def load_openml_dataset(dataset_id, data_dir=None, random_state=0, dataset_forma
|
||||
y_train: A series or array of labels for training data.
|
||||
y_test: A series or array of labels for test data.
|
||||
"""
|
||||
import openml
|
||||
import pickle
|
||||
|
||||
import openml
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
filename = "openml_ds" + str(dataset_id) + ".pkl"
|
||||
@@ -93,9 +96,10 @@ def load_openml_task(task_id, data_dir):
|
||||
y_train: A series of labels for training data.
|
||||
y_test: A series of labels for test data.
|
||||
"""
|
||||
import openml
|
||||
import pickle
|
||||
|
||||
import openml
|
||||
|
||||
task = openml.tasks.get_task(task_id)
|
||||
filename = "openml_task" + str(task_id) + ".pkl"
|
||||
filepath = os.path.join(data_dir, filename)
|
||||
@@ -341,8 +345,8 @@ class DataTransformer:
|
||||
drop = True
|
||||
else:
|
||||
drop = False
|
||||
from sklearn.impute import SimpleImputer
|
||||
from sklearn.compose import ColumnTransformer
|
||||
from sklearn.impute import SimpleImputer
|
||||
|
||||
self.transformer = ColumnTransformer(
|
||||
[
|
||||
|
||||
@@ -2,30 +2,30 @@
|
||||
# * Copyright (c) FLAML authors. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
import time
|
||||
from typing import Union, Callable, TypeVar, Optional, Tuple
|
||||
import logging
|
||||
import time
|
||||
from typing import Callable, Optional, Tuple, TypeVar, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
from flaml.automl.data import group_counts
|
||||
from flaml.automl.task.task import Task
|
||||
from flaml.automl.model import BaseEstimator, TransformersEstimator
|
||||
from flaml.automl.spark import psDataFrame, psSeries, ERROR as SPARK_ERROR, Series, DataFrame
|
||||
from flaml.automl.spark import ERROR as SPARK_ERROR
|
||||
from flaml.automl.spark import DataFrame, Series, psDataFrame, psSeries
|
||||
from flaml.automl.task.task import Task
|
||||
|
||||
try:
|
||||
from sklearn.metrics import (
|
||||
mean_squared_error,
|
||||
r2_score,
|
||||
roc_auc_score,
|
||||
accuracy_score,
|
||||
mean_absolute_error,
|
||||
log_loss,
|
||||
average_precision_score,
|
||||
f1_score,
|
||||
log_loss,
|
||||
mean_absolute_error,
|
||||
mean_absolute_percentage_error,
|
||||
mean_squared_error,
|
||||
ndcg_score,
|
||||
r2_score,
|
||||
roc_auc_score,
|
||||
)
|
||||
except ImportError:
|
||||
pass
|
||||
@@ -323,7 +323,7 @@ def compute_estimator(
|
||||
estimator_name: str,
|
||||
eval_method: str,
|
||||
eval_metric: Union[str, Callable],
|
||||
best_val_loss=np.Inf,
|
||||
best_val_loss=np.inf,
|
||||
n_jobs: Optional[int] = 1, # some estimators of EstimatorSubclass don't accept n_jobs. Should be None in that case.
|
||||
estimator_class: Optional[EstimatorSubclass] = None,
|
||||
cv_score_agg_func: Optional[callable] = None,
|
||||
|
||||
@@ -2,36 +2,43 @@
|
||||
# * Copyright (c) FLAML authors. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from functools import partial
|
||||
import signal
|
||||
import os
|
||||
from typing import Callable, List, Union
|
||||
|
||||
import numpy as np
|
||||
import time
|
||||
import logging
|
||||
import shutil
|
||||
import sys
|
||||
import math
|
||||
|
||||
from flaml import tune
|
||||
from flaml.automl.data import (
|
||||
group_counts,
|
||||
)
|
||||
from flaml.automl.task.factory import task_factory
|
||||
from flaml.automl.task.task import (
|
||||
Task,
|
||||
NLG_TASKS,
|
||||
SEQCLASSIFICATION,
|
||||
SEQREGRESSION,
|
||||
TOKENCLASSIFICATION,
|
||||
SUMMARIZATION,
|
||||
NLG_TASKS,
|
||||
TOKENCLASSIFICATION,
|
||||
Task,
|
||||
)
|
||||
from flaml.automl.task.factory import task_factory
|
||||
|
||||
try:
|
||||
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
|
||||
from sklearn.ensemble import ExtraTreesRegressor, ExtraTreesClassifier
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
from sklearn.dummy import DummyClassifier, DummyRegressor
|
||||
from sklearn.ensemble import (
|
||||
ExtraTreesClassifier,
|
||||
ExtraTreesRegressor,
|
||||
RandomForestClassifier,
|
||||
RandomForestRegressor,
|
||||
)
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
from xgboost import __version__ as xgboost_version
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -40,13 +47,14 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from flaml.automl.spark import psDataFrame, sparkDataFrame, psSeries, ERROR as SPARK_ERROR, DataFrame, Series
|
||||
from flaml.automl.spark.utils import len_labels, to_pandas_on_spark
|
||||
from flaml.automl.spark import ERROR as SPARK_ERROR
|
||||
from flaml.automl.spark import DataFrame, Series, psDataFrame, psSeries, sparkDataFrame
|
||||
from flaml.automl.spark.configs import (
|
||||
ParamList_LightGBM_Classifier,
|
||||
ParamList_LightGBM_Regressor,
|
||||
ParamList_LightGBM_Ranker,
|
||||
ParamList_LightGBM_Regressor,
|
||||
)
|
||||
from flaml.automl.spark.utils import len_labels, to_pandas_on_spark
|
||||
|
||||
if DataFrame is not None:
|
||||
from pandas import to_datetime
|
||||
@@ -61,7 +69,7 @@ except ImportError:
|
||||
resource = None
|
||||
|
||||
try:
|
||||
from lightgbm import LGBMClassifier, LGBMRegressor, LGBMRanker
|
||||
from lightgbm import LGBMClassifier, LGBMRanker, LGBMRegressor
|
||||
except ImportError:
|
||||
LGBMClassifier = LGBMRegressor = LGBMRanker = None
|
||||
|
||||
@@ -212,10 +220,10 @@ class BaseEstimator:
|
||||
model = self.estimator_class(**self.params)
|
||||
if logger.level == logging.DEBUG:
|
||||
# xgboost 1.6 doesn't display all the params in the model str
|
||||
logger.debug(f"flaml.model - {model} fit started with params {self.params}")
|
||||
logger.debug(f"flaml.automl.model - {model} fit started with params {self.params}")
|
||||
model.fit(X_train, y_train, **kwargs)
|
||||
if logger.level == logging.DEBUG:
|
||||
logger.debug(f"flaml.model - {model} fit finished")
|
||||
logger.debug(f"flaml.automl.model - {model} fit finished")
|
||||
train_time = time.time() - current_time
|
||||
self._model = model
|
||||
return train_time
|
||||
@@ -319,8 +327,7 @@ class BaseEstimator:
|
||||
Returns:
|
||||
The evaluation score on the validation dataset.
|
||||
"""
|
||||
from .ml import metric_loss_score
|
||||
from .ml import is_min_metric
|
||||
from .ml import is_min_metric, metric_loss_score
|
||||
|
||||
if self._model is not None:
|
||||
if self._task == "rank":
|
||||
@@ -455,10 +462,10 @@ class SparkEstimator(BaseEstimator):
|
||||
current_time = time.time()
|
||||
pipeline_model = self.estimator_class(**self.params, **kwargs)
|
||||
if logger.level == logging.DEBUG:
|
||||
logger.debug(f"flaml.model - {pipeline_model} fit started with params {self.params}")
|
||||
logger.debug(f"flaml.automl.model - {pipeline_model} fit started with params {self.params}")
|
||||
pipeline_model.fit(df_train)
|
||||
if logger.level == logging.DEBUG:
|
||||
logger.debug(f"flaml.model - {pipeline_model} fit finished")
|
||||
logger.debug(f"flaml.automl.model - {pipeline_model} fit finished")
|
||||
train_time = time.time() - current_time
|
||||
self._model = pipeline_model
|
||||
return train_time
|
||||
@@ -690,12 +697,12 @@ class SparkLGBMEstimator(SparkEstimator):
|
||||
current_time = time.time()
|
||||
model = self.estimator_class(**self.params, **kwargs)
|
||||
if logger.level == logging.DEBUG:
|
||||
logger.debug(f"flaml.model - {model} fit started with params {self.params}")
|
||||
logger.debug(f"flaml.automl.model - {model} fit started with params {self.params}")
|
||||
self._model = model.fit(df_train)
|
||||
self._model.classes_ = self.model_classes_
|
||||
self._model.n_classes_ = self.model_n_classes_
|
||||
if logger.level == logging.DEBUG:
|
||||
logger.debug(f"flaml.model - {model} fit finished")
|
||||
logger.debug(f"flaml.automl.model - {model} fit finished")
|
||||
train_time = time.time() - current_time
|
||||
return train_time
|
||||
|
||||
@@ -758,7 +765,7 @@ class TransformersEstimator(BaseEstimator):
|
||||
return not self._kwargs.get("gpu_per_trial")
|
||||
|
||||
def _set_training_args(self, **kwargs):
|
||||
from .nlp.utils import date_str, Counter
|
||||
from .nlp.utils import Counter, date_str
|
||||
|
||||
for key, val in kwargs.items():
|
||||
assert key not in self.params, (
|
||||
@@ -872,10 +879,10 @@ class TransformersEstimator(BaseEstimator):
|
||||
|
||||
@property
|
||||
def data_collator(self):
|
||||
from flaml.automl.task.task import Task
|
||||
from flaml.automl.nlp.huggingface.data_collator import (
|
||||
task_to_datacollator_class,
|
||||
)
|
||||
from flaml.automl.task.task import Task
|
||||
|
||||
data_collator_class = task_to_datacollator_class.get(
|
||||
self._task.name if isinstance(self._task, Task) else self._task
|
||||
@@ -916,6 +923,7 @@ class TransformersEstimator(BaseEstimator):
|
||||
|
||||
from transformers import TrainerCallback
|
||||
from transformers.trainer_utils import set_seed
|
||||
|
||||
from .nlp.huggingface.trainer import TrainerForAuto
|
||||
|
||||
try:
|
||||
@@ -1145,6 +1153,7 @@ class TransformersEstimator(BaseEstimator):
|
||||
def predict(self, X, **pred_kwargs):
|
||||
import transformers
|
||||
from datasets import Dataset
|
||||
|
||||
from .nlp.huggingface.utils import postprocess_prediction_and_true
|
||||
|
||||
transformers.logging.set_verbosity_error()
|
||||
@@ -1412,7 +1421,7 @@ class LGBMEstimator(BaseEstimator):
|
||||
callbacks = self.params.pop("callbacks")
|
||||
self._model.set_params(callbacks=callbacks[:-1])
|
||||
best_iteration = (
|
||||
self._model.get_booster().best_iteration
|
||||
getattr(self._model.get_booster(), "best_iteration", None)
|
||||
if isinstance(self, XGBoostSklearnEstimator)
|
||||
else self._model.best_iteration_
|
||||
)
|
||||
@@ -1510,8 +1519,6 @@ class XGBoostEstimator(SKLearnEstimator):
|
||||
# params["booster"] = params.get("booster", "gbtree")
|
||||
|
||||
# use_label_encoder is deprecated in 1.7.
|
||||
from xgboost import __version__ as xgboost_version
|
||||
|
||||
if xgboost_version < "1.7.0":
|
||||
params["use_label_encoder"] = params.get("use_label_encoder", False)
|
||||
if "n_jobs" in config:
|
||||
@@ -1559,7 +1566,7 @@ class XGBoostEstimator(SKLearnEstimator):
|
||||
obj=obj,
|
||||
callbacks=callbacks,
|
||||
)
|
||||
self.params["n_estimators"] = self._model.best_iteration + 1
|
||||
self.params["n_estimators"] = getattr(self._model, "best_iteration", _n_estimators - 1) + 1
|
||||
else:
|
||||
self._model = xgb.train(self.params, dtrain, _n_estimators, obj=obj)
|
||||
self.params["n_estimators"] = _n_estimators
|
||||
@@ -1620,7 +1627,9 @@ class XGBoostSklearnEstimator(SKLearnEstimator, LGBMEstimator):
|
||||
if max_depth == 0:
|
||||
params["grow_policy"] = params.get("grow_policy", "lossguide")
|
||||
params["tree_method"] = params.get("tree_method", "hist")
|
||||
params["use_label_encoder"] = params.get("use_label_encoder", False)
|
||||
# use_label_encoder is deprecated in 1.7.
|
||||
if xgboost_version < "1.7.0":
|
||||
params["use_label_encoder"] = params.get("use_label_encoder", False)
|
||||
return params
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
from dataclasses import dataclass
|
||||
from transformers.data.data_collator import (
|
||||
DataCollatorWithPadding,
|
||||
DataCollatorForTokenClassification,
|
||||
DataCollatorForSeq2Seq,
|
||||
)
|
||||
from collections import OrderedDict
|
||||
from dataclasses import dataclass
|
||||
|
||||
from transformers.data.data_collator import (
|
||||
DataCollatorForSeq2Seq,
|
||||
DataCollatorForTokenClassification,
|
||||
DataCollatorWithPadding,
|
||||
)
|
||||
|
||||
from flaml.automl.task.task import (
|
||||
TOKENCLASSIFICATION,
|
||||
MULTICHOICECLASSIFICATION,
|
||||
SUMMARIZATION,
|
||||
SEQCLASSIFICATION,
|
||||
SEQREGRESSION,
|
||||
SUMMARIZATION,
|
||||
TOKENCLASSIFICATION,
|
||||
)
|
||||
|
||||
|
||||
@@ -19,6 +20,7 @@ from flaml.automl.task.task import (
|
||||
class DataCollatorForMultipleChoiceClassification(DataCollatorWithPadding):
|
||||
def __call__(self, features):
|
||||
from itertools import chain
|
||||
|
||||
import torch
|
||||
|
||||
label_name = "label" if "label" in features[0].keys() else "labels"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import argparse
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional, List
|
||||
from typing import List, Optional
|
||||
|
||||
from flaml.automl.task.task import NLG_TASKS
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
from itertools import chain
|
||||
|
||||
import numpy as np
|
||||
from flaml.automl.task.task import (
|
||||
SUMMARIZATION,
|
||||
SEQREGRESSION,
|
||||
SEQCLASSIFICATION,
|
||||
MULTICHOICECLASSIFICATION,
|
||||
TOKENCLASSIFICATION,
|
||||
NLG_TASKS,
|
||||
)
|
||||
|
||||
from flaml.automl.data import pd
|
||||
from flaml.automl.task.task import (
|
||||
MULTICHOICECLASSIFICATION,
|
||||
NLG_TASKS,
|
||||
SEQCLASSIFICATION,
|
||||
SEQREGRESSION,
|
||||
SUMMARIZATION,
|
||||
TOKENCLASSIFICATION,
|
||||
)
|
||||
|
||||
|
||||
def todf(X, Y, column_name):
|
||||
@@ -377,6 +379,7 @@ def load_model(checkpoint_path, task, num_labels=None):
|
||||
transformers.logging.set_verbosity_error()
|
||||
|
||||
from transformers import AutoConfig
|
||||
|
||||
from flaml.automl.task.task import (
|
||||
SEQCLASSIFICATION,
|
||||
SEQREGRESSION,
|
||||
@@ -384,10 +387,12 @@ def load_model(checkpoint_path, task, num_labels=None):
|
||||
)
|
||||
|
||||
def get_this_model(checkpoint_path, task, model_config):
|
||||
from transformers import AutoModelForSequenceClassification
|
||||
from transformers import AutoModelForSeq2SeqLM
|
||||
from transformers import AutoModelForMultipleChoice
|
||||
from transformers import AutoModelForTokenClassification
|
||||
from transformers import (
|
||||
AutoModelForMultipleChoice,
|
||||
AutoModelForSeq2SeqLM,
|
||||
AutoModelForSequenceClassification,
|
||||
AutoModelForTokenClassification,
|
||||
)
|
||||
|
||||
if task in (SEQCLASSIFICATION, SEQREGRESSION):
|
||||
return AutoModelForSequenceClassification.from_pretrained(
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Dict
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.automl.task.task import (
|
||||
SUMMARIZATION,
|
||||
SEQREGRESSION,
|
||||
SEQCLASSIFICATION,
|
||||
MULTICHOICECLASSIFICATION,
|
||||
SEQCLASSIFICATION,
|
||||
SEQREGRESSION,
|
||||
SUMMARIZATION,
|
||||
TOKENCLASSIFICATION,
|
||||
)
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@ try:
|
||||
import pyspark.pandas as ps
|
||||
import pyspark.sql.functions as F
|
||||
import pyspark.sql.types as T
|
||||
from pyspark.pandas import DataFrame as psDataFrame
|
||||
from pyspark.pandas import Series as psSeries
|
||||
from pyspark.pandas import set_option
|
||||
from pyspark.sql import DataFrame as sparkDataFrame
|
||||
from pyspark.pandas import DataFrame as psDataFrame, Series as psSeries, set_option
|
||||
from pyspark.util import VersionUtils
|
||||
except ImportError:
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import numpy as np
|
||||
from typing import Union
|
||||
from flaml.automl.spark import psSeries, F
|
||||
|
||||
import numpy as np
|
||||
from pyspark.ml.evaluation import (
|
||||
BinaryClassificationEvaluator,
|
||||
RegressionEvaluator,
|
||||
MulticlassClassificationEvaluator,
|
||||
MultilabelClassificationEvaluator,
|
||||
RankingEvaluator,
|
||||
RegressionEvaluator,
|
||||
)
|
||||
|
||||
from flaml.automl.spark import F, psSeries
|
||||
|
||||
|
||||
def ps_group_counts(groups: Union[psSeries, np.ndarray]) -> np.ndarray:
|
||||
if isinstance(groups, np.ndarray):
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import logging
|
||||
from typing import Union, List, Optional, Tuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.automl.spark import (
|
||||
sparkDataFrame,
|
||||
ps,
|
||||
DataFrame,
|
||||
F,
|
||||
Series,
|
||||
T,
|
||||
_spark_major_minor_version,
|
||||
ps,
|
||||
psDataFrame,
|
||||
psSeries,
|
||||
_spark_major_minor_version,
|
||||
DataFrame,
|
||||
Series,
|
||||
set_option,
|
||||
sparkDataFrame,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import inspect
|
||||
import copy
|
||||
import inspect
|
||||
import time
|
||||
from typing import Any, Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml import tune
|
||||
from flaml.automl.logger import logger
|
||||
from flaml.automl.ml import compute_estimator, train_estimator
|
||||
from flaml.automl.spark import DataFrame, Series, psDataFrame, psSeries
|
||||
from flaml.automl.time_series.ts_data import TimeSeriesDataset
|
||||
from flaml.automl.spark import psDataFrame, psSeries, DataFrame, Series
|
||||
|
||||
|
||||
class SearchState:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Optional, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.automl.data import DataFrame, Series
|
||||
from flaml.automl.task.task import Task, TS_FORECAST
|
||||
from flaml.automl.task.task import TS_FORECAST, Task
|
||||
|
||||
|
||||
def task_factory(
|
||||
|
||||
@@ -1,43 +1,44 @@
|
||||
import logging
|
||||
import time
|
||||
from typing import List, Optional
|
||||
import numpy as np
|
||||
from flaml.automl.data import TS_TIMESTAMP_COL, concat
|
||||
from flaml.automl.ml import EstimatorSubclass, get_val_loss, default_cv_score_agg_func
|
||||
|
||||
from flaml.automl.task.task import (
|
||||
Task,
|
||||
get_classification_objective,
|
||||
TS_FORECAST,
|
||||
TS_FORECASTPANEL,
|
||||
)
|
||||
from flaml.config import RANDOM_SEED
|
||||
from flaml.automl.spark import ps, psDataFrame, psSeries, pd
|
||||
import numpy as np
|
||||
|
||||
from flaml.automl.data import TS_TIMESTAMP_COL, concat
|
||||
from flaml.automl.ml import EstimatorSubclass, default_cv_score_agg_func, get_val_loss
|
||||
from flaml.automl.spark import pd, ps, psDataFrame, psSeries
|
||||
from flaml.automl.spark.utils import (
|
||||
iloc_pandas_on_spark,
|
||||
len_labels,
|
||||
set_option,
|
||||
spark_kFold,
|
||||
train_test_split_pyspark,
|
||||
unique_pandas_on_spark,
|
||||
unique_value_first_index,
|
||||
len_labels,
|
||||
set_option,
|
||||
)
|
||||
from flaml.automl.task.task import (
|
||||
TS_FORECAST,
|
||||
TS_FORECASTPANEL,
|
||||
Task,
|
||||
get_classification_objective,
|
||||
)
|
||||
from flaml.config import RANDOM_SEED
|
||||
|
||||
try:
|
||||
from scipy.sparse import issparse
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
from sklearn.utils import shuffle
|
||||
from sklearn.model_selection import (
|
||||
train_test_split,
|
||||
RepeatedStratifiedKFold,
|
||||
RepeatedKFold,
|
||||
GroupKFold,
|
||||
TimeSeriesSplit,
|
||||
GroupShuffleSplit,
|
||||
RepeatedKFold,
|
||||
RepeatedStratifiedKFold,
|
||||
StratifiedGroupKFold,
|
||||
TimeSeriesSplit,
|
||||
train_test_split,
|
||||
)
|
||||
from sklearn.utils import shuffle
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -49,19 +50,20 @@ class GenericTask(Task):
|
||||
def estimators(self):
|
||||
if self._estimators is None:
|
||||
# put this into a function to avoid circular dependency
|
||||
from flaml.automl.contrib.histgb import HistGradientBoostingEstimator
|
||||
from flaml.automl.model import (
|
||||
XGBoostSklearnEstimator,
|
||||
XGBoostLimitDepthEstimator,
|
||||
RandomForestEstimator,
|
||||
LGBMEstimator,
|
||||
LRL1Classifier,
|
||||
LRL2Classifier,
|
||||
CatBoostEstimator,
|
||||
ExtraTreesEstimator,
|
||||
KNeighborsEstimator,
|
||||
LGBMEstimator,
|
||||
LRL1Classifier,
|
||||
LRL2Classifier,
|
||||
RandomForestEstimator,
|
||||
SparkLGBMEstimator,
|
||||
TransformersEstimator,
|
||||
TransformersEstimatorModelSelection,
|
||||
SparkLGBMEstimator,
|
||||
XGBoostLimitDepthEstimator,
|
||||
XGBoostSklearnEstimator,
|
||||
)
|
||||
|
||||
self._estimators = {
|
||||
@@ -77,6 +79,7 @@ class GenericTask(Task):
|
||||
"kneighbor": KNeighborsEstimator,
|
||||
"transformer": TransformersEstimator,
|
||||
"transformer_ms": TransformersEstimatorModelSelection,
|
||||
"histgb": HistGradientBoostingEstimator,
|
||||
}
|
||||
return self._estimators
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.automl.data import DataFrame, Series, psDataFrame, psSeries
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -2,26 +2,25 @@ import logging
|
||||
import time
|
||||
from typing import List
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from scipy.sparse import issparse
|
||||
from sklearn.model_selection import (
|
||||
GroupKFold,
|
||||
TimeSeriesSplit,
|
||||
)
|
||||
|
||||
from flaml.automl.ml import get_val_loss, default_cv_score_agg_func
|
||||
from flaml.automl.time_series.ts_data import (
|
||||
TimeSeriesDataset,
|
||||
DataTransformerTS,
|
||||
normalize_ts_data,
|
||||
)
|
||||
|
||||
from flaml.automl.ml import default_cv_score_agg_func, get_val_loss
|
||||
from flaml.automl.task.task import (
|
||||
Task,
|
||||
get_classification_objective,
|
||||
TS_FORECAST,
|
||||
TS_FORECASTPANEL,
|
||||
Task,
|
||||
get_classification_objective,
|
||||
)
|
||||
from flaml.automl.time_series.ts_data import (
|
||||
DataTransformerTS,
|
||||
TimeSeriesDataset,
|
||||
normalize_ts_data,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -33,18 +32,18 @@ class TimeSeriesTask(Task):
|
||||
if self._estimators is None:
|
||||
# put this into a function to avoid circular dependency
|
||||
from flaml.automl.time_series import (
|
||||
ARIMA,
|
||||
LGBM_TS,
|
||||
RF_TS,
|
||||
SARIMAX,
|
||||
CatBoost_TS,
|
||||
ExtraTrees_TS,
|
||||
HoltWinters,
|
||||
Orbit,
|
||||
Prophet,
|
||||
TemporalFusionTransformerEstimator,
|
||||
XGBoost_TS,
|
||||
XGBoostLimitDepth_TS,
|
||||
RF_TS,
|
||||
LGBM_TS,
|
||||
ExtraTrees_TS,
|
||||
CatBoost_TS,
|
||||
Prophet,
|
||||
Orbit,
|
||||
ARIMA,
|
||||
SARIMAX,
|
||||
TemporalFusionTransformerEstimator,
|
||||
HoltWinters,
|
||||
)
|
||||
|
||||
self._estimators = {
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
from .ts_model import (
|
||||
Prophet,
|
||||
Orbit,
|
||||
ARIMA,
|
||||
SARIMAX,
|
||||
HoltWinters,
|
||||
LGBM_TS,
|
||||
XGBoost_TS,
|
||||
RF_TS,
|
||||
ExtraTrees_TS,
|
||||
XGBoostLimitDepth_TS,
|
||||
CatBoost_TS,
|
||||
TimeSeriesEstimator,
|
||||
)
|
||||
from .tft import TemporalFusionTransformerEstimator
|
||||
|
||||
from .ts_data import TimeSeriesDataset
|
||||
from .ts_model import (
|
||||
ARIMA,
|
||||
LGBM_TS,
|
||||
RF_TS,
|
||||
SARIMAX,
|
||||
CatBoost_TS,
|
||||
ExtraTrees_TS,
|
||||
HoltWinters,
|
||||
Orbit,
|
||||
Prophet,
|
||||
TimeSeriesEstimator,
|
||||
XGBoost_TS,
|
||||
XGBoostLimitDepth_TS,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import math
|
||||
import datetime
|
||||
import math
|
||||
from functools import lru_cache
|
||||
|
||||
import pandas as pd
|
||||
|
||||
@@ -12,8 +12,8 @@ except ImportError:
|
||||
DataFrame = Series = None
|
||||
|
||||
import numpy as np
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
from sklearn.decomposition import PCA
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
|
||||
|
||||
def make_lag_features(X: pd.DataFrame, y: pd.Series, lags: int):
|
||||
|
||||
@@ -105,6 +105,7 @@ class TemporalFusionTransformerEstimator(TimeSeriesEstimator):
|
||||
|
||||
def fit(self, X_train, y_train, budget=None, **kwargs):
|
||||
import warnings
|
||||
|
||||
import pytorch_lightning as pl
|
||||
import torch
|
||||
from pytorch_forecasting import TemporalFusionTransformer
|
||||
|
||||
@@ -2,7 +2,7 @@ import copy
|
||||
import datetime
|
||||
import math
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Optional, Callable, Dict, Generator, Union
|
||||
from typing import Callable, Dict, Generator, List, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -10,9 +10,9 @@ try:
|
||||
import pandas as pd
|
||||
from pandas import DataFrame, Series, to_datetime
|
||||
from scipy.sparse import issparse
|
||||
from sklearn.preprocessing import LabelEncoder
|
||||
from sklearn.impute import SimpleImputer
|
||||
from sklearn.compose import ColumnTransformer
|
||||
from sklearn.impute import SimpleImputer
|
||||
from sklearn.preprocessing import LabelEncoder
|
||||
|
||||
from .feature import monthly_fourier_features
|
||||
except ImportError:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import time
|
||||
import logging
|
||||
import os
|
||||
from datetime import datetime
|
||||
import math
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import List, Optional, Union
|
||||
|
||||
try:
|
||||
@@ -22,26 +22,26 @@ except ImportError:
|
||||
import numpy as np
|
||||
|
||||
from flaml import tune
|
||||
from flaml.model import (
|
||||
suppress_stdout_stderr,
|
||||
SKLearnEstimator,
|
||||
logger,
|
||||
LGBMEstimator,
|
||||
XGBoostSklearnEstimator,
|
||||
RandomForestEstimator,
|
||||
ExtraTreesEstimator,
|
||||
XGBoostLimitDepthEstimator,
|
||||
from flaml.automl.data import TS_TIMESTAMP_COL, TS_VALUE_COL
|
||||
from flaml.automl.model import (
|
||||
CatBoostEstimator,
|
||||
)
|
||||
from flaml.data import TS_TIMESTAMP_COL, TS_VALUE_COL
|
||||
from flaml.automl.time_series.ts_data import (
|
||||
TimeSeriesDataset,
|
||||
enrich_dataset,
|
||||
enrich_dataframe,
|
||||
normalize_ts_data,
|
||||
create_forward_frame,
|
||||
ExtraTreesEstimator,
|
||||
LGBMEstimator,
|
||||
RandomForestEstimator,
|
||||
SKLearnEstimator,
|
||||
XGBoostLimitDepthEstimator,
|
||||
XGBoostSklearnEstimator,
|
||||
logger,
|
||||
suppress_stdout_stderr,
|
||||
)
|
||||
from flaml.automl.task import Task
|
||||
from flaml.automl.time_series.ts_data import (
|
||||
TimeSeriesDataset,
|
||||
create_forward_frame,
|
||||
enrich_dataframe,
|
||||
enrich_dataset,
|
||||
normalize_ts_data,
|
||||
)
|
||||
|
||||
|
||||
class TimeSeriesEstimator(SKLearnEstimator):
|
||||
@@ -143,6 +143,7 @@ class TimeSeriesEstimator(SKLearnEstimator):
|
||||
|
||||
def score(self, X_val: DataFrame, y_val: Series, **kwargs):
|
||||
from sklearn.metrics import r2_score
|
||||
|
||||
from ..ml import metric_loss_score
|
||||
|
||||
y_pred = self.predict(X_val, **kwargs)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
"""
|
||||
|
||||
import json
|
||||
from typing import IO
|
||||
from contextlib import contextmanager
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
from typing import IO
|
||||
|
||||
logger = logging.getLogger("flaml.automl")
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import warnings
|
||||
|
||||
from flaml.automl.data import *
|
||||
|
||||
|
||||
warnings.warn(
|
||||
"Importing from `flaml.data` is deprecated. Please use `flaml.automl.data`.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
@@ -1,18 +1,18 @@
|
||||
from .suggest import (
|
||||
suggest_config,
|
||||
suggest_learner,
|
||||
suggest_hyperparams,
|
||||
preprocess_and_suggest_hyperparams,
|
||||
meta_feature,
|
||||
)
|
||||
from .estimator import (
|
||||
flamlize_estimator,
|
||||
LGBMClassifier,
|
||||
LGBMRegressor,
|
||||
XGBClassifier,
|
||||
XGBRegressor,
|
||||
RandomForestClassifier,
|
||||
RandomForestRegressor,
|
||||
ExtraTreesClassifier,
|
||||
ExtraTreesRegressor,
|
||||
LGBMClassifier,
|
||||
LGBMRegressor,
|
||||
RandomForestClassifier,
|
||||
RandomForestRegressor,
|
||||
XGBClassifier,
|
||||
XGBRegressor,
|
||||
flamlize_estimator,
|
||||
)
|
||||
from .suggest import (
|
||||
meta_feature,
|
||||
preprocess_and_suggest_hyperparams,
|
||||
suggest_config,
|
||||
suggest_hyperparams,
|
||||
suggest_learner,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from functools import wraps
|
||||
|
||||
from flaml.automl.task.task import CLASSIFICATION
|
||||
|
||||
from .suggest import preprocess_and_suggest_hyperparams
|
||||
|
||||
DEFAULT_LOCATION = "default_location"
|
||||
@@ -105,7 +107,12 @@ def flamlize_estimator(super_class, name: str, task: str, alternatives=None):
|
||||
# if hasattr(self, "_classes"):
|
||||
# self._classes = self._label_transformer.classes_
|
||||
# else:
|
||||
self.classes_ = self._label_transformer.classes_
|
||||
try:
|
||||
self.classes_ = self._label_transformer.classes_
|
||||
except AttributeError:
|
||||
# xgboost 2: AttributeError: can't set attribute
|
||||
if "xgb" not in estimator_name:
|
||||
raise
|
||||
if "xgb" not in estimator_name:
|
||||
# rf and et would do inverse transform automatically; xgb doesn't
|
||||
self._label_transformer = None
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from sklearn.preprocessing import RobustScaler
|
||||
from sklearn.metrics import pairwise_distances
|
||||
from sklearn.preprocessing import RobustScaler
|
||||
|
||||
|
||||
def _augment(row):
|
||||
@@ -12,7 +12,7 @@ def _augment(row):
|
||||
def construct_portfolio(regret_matrix, meta_features, regret_bound):
|
||||
"""The portfolio construction algorithm.
|
||||
|
||||
(Reference)[https://arxiv.org/abs/2202.09927].
|
||||
Reference: [Mining Robust Default Configurations for Resource-constrained AutoML](https://arxiv.org/abs/2202.09927).
|
||||
|
||||
Args:
|
||||
regret_matrix: A dataframe of regret matrix.
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from sklearn.preprocessing import RobustScaler
|
||||
|
||||
from flaml.default import greedy
|
||||
from flaml.default.regret import load_result, build_regret
|
||||
from flaml.default.regret import build_regret, load_result
|
||||
from flaml.version import __version__
|
||||
|
||||
regret_bound = 0.01
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import argparse
|
||||
from os import path
|
||||
|
||||
import pandas as pd
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import numpy as np
|
||||
import json
|
||||
import logging
|
||||
import pathlib
|
||||
import json
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.automl.data import DataTransformer
|
||||
from flaml.automl.task.task import CLASSIFICATION, get_classification_objective
|
||||
from flaml.automl.task.generic_task import len_labels
|
||||
from flaml.automl.task.factory import task_factory
|
||||
from flaml.automl.task.generic_task import len_labels
|
||||
from flaml.automl.task.task import CLASSIFICATION, get_classification_objective
|
||||
from flaml.version import __version__
|
||||
|
||||
try:
|
||||
|
||||
@@ -2,7 +2,6 @@ import warnings
|
||||
|
||||
from flaml.automl.ml import *
|
||||
|
||||
|
||||
warnings.warn(
|
||||
"Importing from `flaml.ml` is deprecated. Please use `flaml.automl.ml`.",
|
||||
DeprecationWarning,
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import warnings
|
||||
|
||||
from flaml.automl.model import *
|
||||
|
||||
|
||||
warnings.warn(
|
||||
"Importing from `flaml.model` is deprecated. Please use `flaml.automl.model`.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
@@ -1,16 +1,17 @@
|
||||
from typing import Optional, Union
|
||||
import logging
|
||||
from typing import Optional, Union
|
||||
|
||||
from flaml.onlineml import OnlineTrialRunner
|
||||
from flaml.onlineml.trial import get_ns_feature_dim_from_vw_example
|
||||
from flaml.tune import (
|
||||
Trial,
|
||||
Categorical,
|
||||
Float,
|
||||
PolynomialExpansionSet,
|
||||
Trial,
|
||||
polynomial_expansion_set,
|
||||
)
|
||||
from flaml.onlineml import OnlineTrialRunner
|
||||
from flaml.tune.scheduler import ChaChaScheduler
|
||||
from flaml.tune.searcher import ChampionFrontierSearcher
|
||||
from flaml.onlineml.trial import get_ns_feature_dim_from_vw_example
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -140,7 +141,7 @@ class AutoVW:
|
||||
max_live_model_num=self._max_live_model_num,
|
||||
searcher=searcher,
|
||||
scheduler=scheduler,
|
||||
**self._automl_runner_args
|
||||
**self._automl_runner_args,
|
||||
)
|
||||
|
||||
def predict(self, data_sample):
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import numpy as np
|
||||
import logging
|
||||
import time
|
||||
import math
|
||||
import copy
|
||||
import collections
|
||||
import copy
|
||||
import logging
|
||||
import math
|
||||
import time
|
||||
from typing import Optional, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.tune import Trial
|
||||
|
||||
try:
|
||||
from sklearn.metrics import mean_squared_error, mean_absolute_error
|
||||
from sklearn.metrics import mean_absolute_error, mean_squared_error
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import numpy as np
|
||||
import logging
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.tune import Trial
|
||||
from flaml.tune.scheduler import TrialScheduler
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ try:
|
||||
|
||||
assert ray_version >= "1.10.0"
|
||||
from ray.tune import (
|
||||
uniform,
|
||||
lograndint,
|
||||
loguniform,
|
||||
qlograndint,
|
||||
qloguniform,
|
||||
qrandint,
|
||||
qrandn,
|
||||
quniform,
|
||||
randint,
|
||||
qrandint,
|
||||
randn,
|
||||
qrandn,
|
||||
loguniform,
|
||||
qloguniform,
|
||||
lograndint,
|
||||
qlograndint,
|
||||
uniform,
|
||||
)
|
||||
|
||||
if ray_version.startswith("1."):
|
||||
@@ -20,21 +20,20 @@ try:
|
||||
else:
|
||||
from ray.tune.search import sample
|
||||
except (ImportError, AssertionError):
|
||||
from . import sample
|
||||
from .sample import (
|
||||
uniform,
|
||||
lograndint,
|
||||
loguniform,
|
||||
qlograndint,
|
||||
qloguniform,
|
||||
qrandint,
|
||||
qrandn,
|
||||
quniform,
|
||||
randint,
|
||||
qrandint,
|
||||
randn,
|
||||
qrandn,
|
||||
loguniform,
|
||||
qloguniform,
|
||||
lograndint,
|
||||
qlograndint,
|
||||
uniform,
|
||||
)
|
||||
from . import sample
|
||||
from .tune import run, report, INCUMBENT_RESULT
|
||||
from .sample import polynomial_expansion_set
|
||||
from .sample import PolynomialExpansionSet, Categorical, Float
|
||||
from .sample import Categorical, Float, PolynomialExpansionSet, polynomial_expansion_set
|
||||
from .trial import Trial
|
||||
from .tune import INCUMBENT_RESULT, report, run
|
||||
from .utils import choice
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
# This source file is adapted here because ray does not fully support Windows.
|
||||
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
from typing import Dict, Optional
|
||||
import numpy as np
|
||||
from .trial import Trial
|
||||
import logging
|
||||
from typing import Dict, Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .trial import Trial
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import logging
|
||||
from copy import copy
|
||||
from math import isclose
|
||||
from typing import Any, Dict, List, Optional, Sequence, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
# Backwards compatibility
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from .trial_scheduler import TrialScheduler
|
||||
from .online_scheduler import (
|
||||
ChaChaScheduler,
|
||||
OnlineScheduler,
|
||||
OnlineSuccessiveDoublingScheduler,
|
||||
ChaChaScheduler,
|
||||
)
|
||||
from .trial_scheduler import TrialScheduler
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import numpy as np
|
||||
import logging
|
||||
from typing import Dict
|
||||
from flaml.tune.scheduler import TrialScheduler
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.tune import Trial
|
||||
|
||||
from .trial_scheduler import TrialScheduler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
# * Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
from typing import Dict, Optional, List, Tuple, Callable, Union
|
||||
import numpy as np
|
||||
import time
|
||||
import pickle
|
||||
import time
|
||||
from typing import Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
from ray import __version__ as ray_version
|
||||
@@ -18,17 +19,17 @@ try:
|
||||
from ray.tune.search import Searcher
|
||||
from ray.tune.search.optuna import OptunaSearch as GlobalSearch
|
||||
except (ImportError, AssertionError):
|
||||
from .suggestion import Searcher
|
||||
from .suggestion import OptunaSearch as GlobalSearch
|
||||
from ..trial import unflatten_dict, flatten_dict
|
||||
from .. import INCUMBENT_RESULT
|
||||
from .search_thread import SearchThread
|
||||
from .flow2 import FLOW2
|
||||
from ..space import add_cost_to_space, indexof, normalize, define_by_run_func
|
||||
from ..result import TIME_TOTAL_S
|
||||
|
||||
from .suggestion import Searcher
|
||||
import logging
|
||||
|
||||
from .. import INCUMBENT_RESULT
|
||||
from ..result import TIME_TOTAL_S
|
||||
from ..space import add_cost_to_space, define_by_run_func, indexof, normalize
|
||||
from ..trial import flatten_dict, unflatten_dict
|
||||
from .flow2 import FLOW2
|
||||
from .search_thread import SearchThread
|
||||
|
||||
SEARCH_THREAD_EPS = 1.0
|
||||
PENALTY = 1e10 # penalty term for constraints
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -931,27 +932,27 @@ try:
|
||||
|
||||
assert ray_version >= "1.10.0"
|
||||
from ray.tune import (
|
||||
uniform,
|
||||
quniform,
|
||||
choice,
|
||||
randint,
|
||||
qrandint,
|
||||
randn,
|
||||
qrandn,
|
||||
loguniform,
|
||||
qloguniform,
|
||||
qrandint,
|
||||
qrandn,
|
||||
quniform,
|
||||
randint,
|
||||
randn,
|
||||
uniform,
|
||||
)
|
||||
except (ImportError, AssertionError):
|
||||
from ..sample import (
|
||||
uniform,
|
||||
quniform,
|
||||
choice,
|
||||
randint,
|
||||
qrandint,
|
||||
randn,
|
||||
qrandn,
|
||||
loguniform,
|
||||
qloguniform,
|
||||
qrandint,
|
||||
qrandn,
|
||||
quniform,
|
||||
randint,
|
||||
randn,
|
||||
uniform,
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -978,7 +979,7 @@ class BlendSearchTuner(BlendSearch, NNITuner):
|
||||
result = {
|
||||
"config": parameters,
|
||||
self._metric: extract_scalar_reward(value),
|
||||
self.cost_attr: 1 if isinstance(value, float) else value.get(self.cost_attr, value.get("sequence", 1))
|
||||
self.cost_attr: 1 if isinstance(value, float) else value.get(self.cost_attr, value.get("sequence", 1)),
|
||||
# if nni does not report training cost,
|
||||
# using sequence as an approximation.
|
||||
# if no sequence, using a constant 1
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# * Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
from .flow2 import FLOW2
|
||||
from .blendsearch import CFO
|
||||
from .flow2 import FLOW2
|
||||
|
||||
|
||||
class FLOW2Cat(FLOW2):
|
||||
|
||||
@@ -2,31 +2,34 @@
|
||||
# * Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
from typing import Dict, Optional, Tuple
|
||||
import numpy as np
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
from typing import Dict, Optional, Tuple
|
||||
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
from ray import __version__ as ray_version
|
||||
|
||||
assert ray_version >= "1.0.0"
|
||||
if ray_version.startswith("1."):
|
||||
from ray.tune.suggest import Searcher
|
||||
from ray.tune import sample
|
||||
from ray.tune.suggest import Searcher
|
||||
else:
|
||||
from ray.tune.search import Searcher, sample
|
||||
from ray.tune.utils.util import flatten_dict, unflatten_dict
|
||||
except (ImportError, AssertionError):
|
||||
from .suggestion import Searcher
|
||||
from flaml.tune import sample
|
||||
|
||||
from ..trial import flatten_dict, unflatten_dict
|
||||
from .suggestion import Searcher
|
||||
from flaml.config import SAMPLE_MULTIPLY_FACTOR
|
||||
|
||||
from ..space import (
|
||||
complete_config,
|
||||
denormalize,
|
||||
normalize,
|
||||
generate_variants_compatible,
|
||||
normalize,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -135,7 +138,7 @@ class FLOW2(Searcher):
|
||||
self.max_resource = max_resource
|
||||
self._resource = None
|
||||
self._f_best = None # only use for lexico_comapre. It represent the best value achieved by lexico_flow.
|
||||
self._step_lb = np.Inf
|
||||
self._step_lb = np.inf
|
||||
self._histories = None # only use for lexico_comapre. It records the result of historical configurations.
|
||||
if space is not None:
|
||||
self._init_search()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import numpy as np
|
||||
import logging
|
||||
import itertools
|
||||
from typing import Dict, Optional, List
|
||||
from flaml.tune import Categorical, Float, PolynomialExpansionSet, Trial
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from flaml.onlineml import VowpalWabbitTrial
|
||||
from flaml.tune import Categorical, Float, PolynomialExpansionSet, Trial
|
||||
from flaml.tune.searcher import CFO
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
from typing import Dict, Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
@@ -15,11 +16,12 @@ try:
|
||||
from ray.tune.search import Searcher
|
||||
except (ImportError, AssertionError):
|
||||
from .suggestion import Searcher
|
||||
from .flow2 import FLOW2
|
||||
from ..space import add_cost_to_space, unflatten_hierarchical
|
||||
from ..result import TIME_TOTAL_S
|
||||
import logging
|
||||
|
||||
from ..result import TIME_TOTAL_S
|
||||
from ..space import add_cost_to_space, unflatten_hierarchical
|
||||
from .flow2 import FLOW2
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -15,15 +15,17 @@
|
||||
# This source file is adapted here because ray does not fully support Windows.
|
||||
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
import time
|
||||
import functools
|
||||
import warnings
|
||||
import copy
|
||||
import numpy as np
|
||||
import functools
|
||||
import logging
|
||||
from typing import Any, Dict, Optional, Union, List, Tuple, Callable
|
||||
import pickle
|
||||
from .variant_generator import parse_spec_vars
|
||||
import time
|
||||
import warnings
|
||||
from collections import defaultdict
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..sample import (
|
||||
Categorical,
|
||||
Domain,
|
||||
@@ -34,7 +36,7 @@ from ..sample import (
|
||||
Uniform,
|
||||
)
|
||||
from ..trial import flatten_dict, unflatten_dict
|
||||
from collections import defaultdict
|
||||
from .variant_generator import parse_spec_vars
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -183,7 +185,7 @@ class ConcurrencyLimiter(Searcher):
|
||||
"""
|
||||
|
||||
def __init__(self, searcher: Searcher, max_concurrent: int, batch: bool = False):
|
||||
assert type(max_concurrent) is int and max_concurrent > 0
|
||||
assert isinstance(max_concurrent, int) and max_concurrent > 0
|
||||
self.searcher = searcher
|
||||
self.max_concurrent = max_concurrent
|
||||
self.batch = batch
|
||||
@@ -252,8 +254,8 @@ try:
|
||||
import optuna as ot
|
||||
from optuna.distributions import BaseDistribution as OptunaDistribution
|
||||
from optuna.samplers import BaseSampler
|
||||
from optuna.trial import TrialState as OptunaTrialState
|
||||
from optuna.trial import Trial as OptunaTrial
|
||||
from optuna.trial import TrialState as OptunaTrialState
|
||||
except ImportError:
|
||||
ot = None
|
||||
OptunaDistribution = None
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
import copy
|
||||
import logging
|
||||
from typing import Any, Dict, Generator, List, Tuple
|
||||
import numpy
|
||||
import random
|
||||
from typing import Any, Dict, Generator, List, Tuple
|
||||
|
||||
import numpy
|
||||
|
||||
from ..sample import Categorical, Domain, RandomState
|
||||
|
||||
try:
|
||||
|
||||
@@ -11,9 +11,10 @@ try:
|
||||
except (ImportError, AssertionError):
|
||||
from . import sample
|
||||
from .searcher.variant_generator import generate_variants
|
||||
from typing import Dict, Optional, Any, Tuple, Generator, List, Union
|
||||
import numpy as np
|
||||
import logging
|
||||
from typing import Any, Dict, Generator, List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -489,7 +490,7 @@ def complete_config(
|
||||
elif domain.bounded:
|
||||
up, low, gauss_std = 1, 0, 1.0
|
||||
else:
|
||||
up, low, gauss_std = np.Inf, -np.Inf, 1.0
|
||||
up, low, gauss_std = np.inf, -np.inf, 1.0
|
||||
if domain.bounded:
|
||||
if isinstance(up, list):
|
||||
up[-1] = min(up[-1], 1)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from flaml.tune.spark.utils import (
|
||||
broadcast_code,
|
||||
check_spark,
|
||||
get_n_cpus,
|
||||
with_parameters,
|
||||
broadcast_code,
|
||||
)
|
||||
|
||||
__all__ = ["check_spark", "get_n_cpus", "with_parameters", "broadcast_code"]
|
||||
|
||||
@@ -5,7 +5,6 @@ import threading
|
||||
import time
|
||||
from functools import lru_cache, partial
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger_formatter = logging.Formatter(
|
||||
"[%(name)s: %(asctime)s] {%(lineno)d} %(levelname)s - %(message)s", "%m-%d %H:%M:%S"
|
||||
@@ -13,10 +12,10 @@ logger_formatter = logging.Formatter(
|
||||
logger.propagate = False
|
||||
os.environ["PYARROW_IGNORE_TIMEZONE"] = "1"
|
||||
try:
|
||||
import py4j
|
||||
import pyspark
|
||||
from pyspark.sql import SparkSession
|
||||
from pyspark.util import VersionUtils
|
||||
import py4j
|
||||
except ImportError:
|
||||
_have_spark = False
|
||||
py4j = None
|
||||
@@ -286,6 +285,7 @@ class PySparkOvertimeMonitor:
|
||||
def __exit__(self, exc_type, exc_value, exc_traceback):
|
||||
"""Exit the context manager.
|
||||
This will wait for the monitor thread to nicely exit."""
|
||||
logger.debug(f"monitor exited: {exc_type}, {exc_value}, {exc_traceback}")
|
||||
if self._force_cancel and _have_spark:
|
||||
self._finished_flag = True
|
||||
self._monitor_daemon.join()
|
||||
@@ -296,6 +296,11 @@ class PySparkOvertimeMonitor:
|
||||
if not exc_type:
|
||||
return True
|
||||
elif exc_type == py4j.protocol.Py4JJavaError:
|
||||
logger.debug("Py4JJavaError Exception: %s", exc_value)
|
||||
return True
|
||||
elif exc_type == TypeError:
|
||||
# When force cancel, joblib>1.2.0 will raise joblib.externals.loky.process_executor._ExceptionWithTraceback
|
||||
logger.debug("TypeError Exception: %s", exc_value)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
# This source file is adapted here because ray does not fully support Windows.
|
||||
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
import uuid
|
||||
import time
|
||||
from numbers import Number
|
||||
import uuid
|
||||
from collections import deque
|
||||
from numbers import Number
|
||||
|
||||
|
||||
def flatten_dict(dt, delimiter="/", prevent_delimiter=False):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# * Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
# try:
|
||||
@@ -10,7 +11,6 @@ from typing import Optional
|
||||
# from ray.tune.trial import Trial
|
||||
# except (ImportError, AssertionError):
|
||||
from .trial import Trial
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
# * Copyright (c) FLAML authors. All rights reserved.
|
||||
# * Licensed under the MIT License. See LICENSE file in the
|
||||
# * project root for license information.
|
||||
from typing import Optional, Union, List, Callable, Tuple, Dict
|
||||
import numpy as np
|
||||
import datetime
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from typing import Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
from ray import __version__ as ray_version
|
||||
@@ -21,11 +22,13 @@ except (ImportError, AssertionError):
|
||||
else:
|
||||
ray_available = True
|
||||
|
||||
from .trial import Trial
|
||||
from .result import DEFAULT_METRIC
|
||||
import logging
|
||||
|
||||
from flaml.tune.spark.utils import PySparkOvertimeMonitor, check_spark
|
||||
|
||||
from .result import DEFAULT_METRIC
|
||||
from .trial import Trial
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.propagate = False
|
||||
_use_ray = True
|
||||
@@ -92,10 +95,12 @@ class ExperimentAnalysis(EA):
|
||||
feasible_index_filter = np.where(
|
||||
feasible_value
|
||||
<= max(
|
||||
f_best[k_metric] + self.lexico_objectives["tolerances"][k_metric]
|
||||
if not isinstance(self.lexico_objectives["tolerances"][k_metric], str)
|
||||
else f_best[k_metric]
|
||||
* (1 + 0.01 * float(self.lexico_objectives["tolerances"][k_metric].replace("%", ""))),
|
||||
(
|
||||
f_best[k_metric] + self.lexico_objectives["tolerances"][k_metric]
|
||||
if not isinstance(self.lexico_objectives["tolerances"][k_metric], str)
|
||||
else f_best[k_metric]
|
||||
* (1 + 0.01 * float(self.lexico_objectives["tolerances"][k_metric].replace("%", "")))
|
||||
),
|
||||
k_target,
|
||||
)
|
||||
)[0]
|
||||
@@ -481,7 +486,7 @@ def run(
|
||||
else:
|
||||
logger.setLevel(logging.CRITICAL)
|
||||
|
||||
from .searcher.blendsearch import BlendSearch, CFO, RandomSearch
|
||||
from .searcher.blendsearch import CFO, BlendSearch, RandomSearch
|
||||
|
||||
if lexico_objectives is not None:
|
||||
if "modes" not in lexico_objectives.keys():
|
||||
@@ -650,12 +655,13 @@ def run(
|
||||
if not spark_available:
|
||||
raise spark_error_msg
|
||||
try:
|
||||
from pyspark.sql import SparkSession
|
||||
from joblib import Parallel, delayed, parallel_backend
|
||||
from joblibspark import register_spark
|
||||
from pyspark.sql import SparkSession
|
||||
except ImportError as e:
|
||||
raise ImportError(f"{e}. Try pip install flaml[spark] or set use_spark=False.")
|
||||
from flaml.tune.searcher.suggestion import ConcurrencyLimiter
|
||||
|
||||
from .trial_runner import SparkTrialRunner
|
||||
|
||||
register_spark()
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "2.0.2"
|
||||
__version__ = "2.1.2"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"source": [
|
||||
"# Auto Generated Agent Chat: Using MathChat to Solve Math Problems\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"MathChat is an experimental convesational framework for math problem solving. In this notebook, we demonstrate how to use MathChat to solve math problems. MathChat uses the `AssistantAgent` and `MathUserProxyAgent`, which is similar to the usage of `AssistantAgent` and `UserProxyAgent` in other notebooks (e.g., [Automated Task Solving with Code Generation, Execution & Debugging](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_auto_feedback_from_code_execution.ipynb)). Essentially, `MathUserProxyAgent` implements a different auto reply mechanism corresponding to the MathChat prompts. You can find more details in the paper [An Empirical Study on Challenging Math Problem Solving with GPT-4](https://arxiv.org/abs/2306.01337) or the [blogpost](https://microsoft.github.io/FLAML/blog/2023/06/28/MathChat).\n",
|
||||
"\n",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"# Auto Generated Agent Chat: Using RetrieveChat for Retrieve Augmented Code Generation and Question Answering\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"RetrieveChat is a convesational system for retrieve augmented code generation and question answering. In this notebook, we demonstrate how to utilize RetrieveChat to generate code and answer questions based on customized documentations that are not present in the LLM's training dataset. RetrieveChat uses the `RetrieveAssistantAgent` and `RetrieveUserProxyAgent`, which is similar to the usage of `AssistantAgent` and `UserProxyAgent` in other notebooks (e.g., [Automated Task Solving with Code Generation, Execution & Debugging](https://github.com/microsoft/FLAML/blob/main/notebook/autogen_agentchat_auto_feedback_from_code_execution.ipynb)). Essentially, `RetrieveAssistantAgent` and `RetrieveUserProxyAgent` implement a different auto-reply mechanism corresponding to the RetrieveChat prompts.\n",
|
||||
"\n",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"# Auto Generated Agent Chat: Task Solving with Code Generation, Execution & Debugging\n",
|
||||
"\n",
|
||||
"FLAML offers conversable LLM agents, which can be used to solve various tasks with human or automatic feedback, including tasks that require using tools via code.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use `AssistantAgent` and `UserProxyAgent` to write code and execute the code. Here `AssistantAgent` is an LLM-based agent that can write Python code (in a Python coding block) for a user to execute for a given task. `UserProxyAgent` is an agent which serves as a proxy for the human user to execute the code written by `AssistantAgent`, or automatically execute the code. Depending on the setting of `human_input_mode` and `max_consecutive_auto_reply`, the `UserProxyAgent` either solicits feedback from the human user or returns auto-feedback based on the result of code execution (success or failure and corresponding outputs) to `AssistantAgent`. `AssistantAgent` will debug the code and suggest new code if the result contains error. The two agents keep communicating to each other until the task is done.\n",
|
||||
"\n",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"# Auto Generated Agent Chat: Chess Game Playing While Chitchatting by GPT-4 Agents\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"This notebook is modified based on https://github.com/ekzhu/FLAML/blob/evaluation/evaluation/chess/play_chess.ipynb\n",
|
||||
"\n",
|
||||
@@ -35,7 +35,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%capture --no-stderr\n",
|
||||
"# %pip install flaml[autogen]~=2.0.0\n",
|
||||
"# %pip install flaml[autogen]~=2.1.0\n",
|
||||
"%pip install chess -U"
|
||||
]
|
||||
},
|
||||
@@ -79,6 +79,7 @@
|
||||
"# \"model\": {\n",
|
||||
"# \"gpt-3.5-turbo\",\n",
|
||||
"# \"gpt-3.5-turbo-16k\",\n",
|
||||
"# \"gpt-3.5-turbo-16k-0613\",\n",
|
||||
"# \"gpt-3.5-turbo-0301\",\n",
|
||||
"# \"chatgpt-35-turbo-0301\",\n",
|
||||
"# \"gpt-35-turbo-v0301\",\n",
|
||||
@@ -157,7 +158,7 @@
|
||||
" llm_config={\"temperature\": 0.0, \"config_list\": config_list_gpt4},\n",
|
||||
" max_consecutive_auto_reply=10,\n",
|
||||
" )\n",
|
||||
" self.register_auto_reply(autogen.ResponsiveAgent, BoardAgent._generate_board_reply)\n",
|
||||
" self.register_reply(autogen.ConversableAgent, BoardAgent._generate_board_reply)\n",
|
||||
" self.board = board\n",
|
||||
" self.correct_move_messages = defaultdict(list)\n",
|
||||
"\n",
|
||||
@@ -225,8 +226,8 @@
|
||||
" max_consecutive_auto_reply=max_turns,\n",
|
||||
" **kwargs,\n",
|
||||
" )\n",
|
||||
" self.register_auto_reply(BoardAgent, ChessPlayerAgent._generate_reply_for_board, config=board_agent.board)\n",
|
||||
" self.register_auto_reply(ChessPlayerAgent, ChessPlayerAgent._generate_reply_for_player, config=board_agent)\n",
|
||||
" self.register_reply(BoardAgent, ChessPlayerAgent._generate_reply_for_board, config=board_agent.board)\n",
|
||||
" self.register_reply(ChessPlayerAgent, ChessPlayerAgent._generate_reply_for_player, config=board_agent)\n",
|
||||
" self.update_max_consecutive_auto_reply(board_agent.max_consecutive_auto_reply(), board_agent)\n",
|
||||
"\n",
|
||||
" def _generate_reply_for_board(\n",
|
||||
@@ -261,7 +262,7 @@
|
||||
" return True, None\n",
|
||||
" # converse with the board until a legal move is made or max allowed retries.\n",
|
||||
" # change silent to False to see that conversation.\n",
|
||||
" self.initiate_chat(board_agent, clear_history=False, message=message, silent=True)\n",
|
||||
" self.initiate_chat(board_agent, clear_history=False, message=message, silent=self.human_input_mode == \"NEVER\")\n",
|
||||
" # last message sent by the board agent\n",
|
||||
" last_message = self._oai_messages[board_agent][-1]\n",
|
||||
" if last_message[\"role\"] == \"assistant\":\n",
|
||||
@@ -1009,7 +1010,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
"version": "3.9.17"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"source": [
|
||||
"# Auto Generated Agent Chat: Task Solving with Provided Tools as Functions\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use `AssistantAgent` and `UserProxyAgent` to make function calls with the new feature of OpenAI models (in model version 0613). A specified prompt and function configs need to be passed to `AssistantAgent` to initialize the agent. The corresponding functions need to be passed to `UserProxyAgent`, which will be responsible for executing any function calls made by `AssistantAgent`. Besides this requirement of matching descriptions with functions, we recommend checking the system message in the `AssistantAgent` to make sure the instructions align with the function call descriptions.\n",
|
||||
"\n",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"# Auto Generated Agent Chat: Group Chat\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"This notebook is modified based on https://github.com/microsoft/FLAML/blob/4ea686af5c3e8ff24d9076a7a626c8b28ab5b1d7/notebook/autogen_multiagent_roleplay_chat.ipynb\n",
|
||||
"\n",
|
||||
@@ -30,7 +30,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 105,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -50,7 +50,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 106,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -122,26 +122,27 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 107,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"llm_config = {\"config_list\": config_list_gpt4}\n",
|
||||
"human = autogen.UserProxyAgent(\n",
|
||||
" name=\"Human\",\n",
|
||||
"llm_config = {\"config_list\": config_list_gpt4, \"seed\": 42}\n",
|
||||
"user_proxy = autogen.UserProxyAgent(\n",
|
||||
" name=\"User_proxy\",\n",
|
||||
" system_message=\"A human admin.\",\n",
|
||||
" code_execution_config={\"last_n_messages\": 2, \"work_dir\": \"groupchat\"},\n",
|
||||
" human_input_mode=\"TERMINATE\"\n",
|
||||
")\n",
|
||||
"alice = autogen.AssistantAgent(\n",
|
||||
" name=\"Alice\",\n",
|
||||
"coder = autogen.AssistantAgent(\n",
|
||||
" name=\"Coder\",\n",
|
||||
" llm_config=llm_config,\n",
|
||||
")\n",
|
||||
"bob = autogen.AssistantAgent(\n",
|
||||
" name=\"Bob\",\n",
|
||||
" system_message=\"Scientist. Provide expert knowledge.\",\n",
|
||||
"pm = autogen.AssistantAgent(\n",
|
||||
" name=\"Product_manager\",\n",
|
||||
" system_message=\"Creative in software product ideas.\",\n",
|
||||
" llm_config=llm_config,\n",
|
||||
")\n",
|
||||
"groupchat = autogen.GroupChat(agents=[human, alice, bob], messages=[], max_round=12)\n",
|
||||
"groupchat = autogen.GroupChat(agents=[user_proxy, coder, pm], messages=[], max_round=12)\n",
|
||||
"manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)"
|
||||
]
|
||||
},
|
||||
@@ -155,133 +156,112 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 108,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[33mHuman\u001b[0m (to chat_manager):\n",
|
||||
"\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"Find a latest paper about gpt-4 on arxiv and find its potential application.\n",
|
||||
"Find a latest paper about gpt-4 on arxiv and find its potential applications in software.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mAlice\u001b[0m (to chat_manager):\n",
|
||||
"\u001b[33mCoder\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"To find the latest paper about GPT-4 on arxiv, I will use the arxiv API to query and filter the search results. First, I'll execute the following code to get the latest paper information.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mAlice\u001b[0m (to chat_manager):\n",
|
||||
"To find the latest paper about GPT-4 on arxiv, I'll provide you with a Python code that fetches the most recent papers from the arxiv API and filters the results to get the most relevant paper related to GPT-4. After fetching the paper, I'll extract the information for potential applications in software. Please execute the following Python code:\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"import requests\n",
|
||||
"from bs4 import BeautifulSoup\n",
|
||||
"import re\n",
|
||||
"\n",
|
||||
"def fetch_arxiv_papers(query):\n",
|
||||
" base_url = \"http://export.arxiv.org/api/query?\"\n",
|
||||
" search_query = \"all:\" + query\n",
|
||||
" response = requests.get(base_url, params={\"search_query\": search_query, \"sortBy\": \"submittedDate\", \"sortOrder\": \"descending\"})\n",
|
||||
" return BeautifulSoup(response.content, \"xml\")\n",
|
||||
"\n",
|
||||
"def search_arxiv(query, sort_by=\"submittedDate\", order=\"descending\", max_results=1):\n",
|
||||
" search_url = \"http://export.arxiv.org/api/query\"\n",
|
||||
" query_string = f\"search_query=all:{query.replace(' ', '+')}&sortBy={sort_by}&sortOrder={order}&max_results={max_results}\"\n",
|
||||
" url = f\"{search_url}?{query_string}\"\n",
|
||||
" response = requests.get(url)\n",
|
||||
" return response.text\n",
|
||||
"def find_gpt4_paper():\n",
|
||||
" papers = fetch_arxiv_papers(\"gpt-4\")\n",
|
||||
" for entry in papers.find_all(\"entry\"):\n",
|
||||
" title = entry.title.text.strip()\n",
|
||||
" summary = entry.summary.text.strip()\n",
|
||||
" if \"gpt-4\" in title.lower() or \"gpt-4\" in summary.lower():\n",
|
||||
" return {\"title\": title, \"summary\": summary}\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def parse_paper_info(xml_response):\n",
|
||||
" soup = BeautifulSoup(xml_response, \"lxml-xml\")\n",
|
||||
" entry = soup.find(\"entry\")\n",
|
||||
" if not entry:\n",
|
||||
" return {}\n",
|
||||
"\n",
|
||||
" paper_info = {\n",
|
||||
" \"title\": entry.find(\"title\").text.strip(),\n",
|
||||
" \"authors\": [author.text for author in entry.find_all(\"author\")],\n",
|
||||
" \"published\": entry.find(\"published\").text,\n",
|
||||
" \"updated\": entry.find(\"updated\").text,\n",
|
||||
" \"summary\": entry.find(\"summary\").text.strip(),\n",
|
||||
" \"url\": entry.find(\"id\").text,\n",
|
||||
" }\n",
|
||||
" return paper_info\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"query = \"gpt-4\"\n",
|
||||
"arxiv_response = search_arxiv(query)\n",
|
||||
"paper_info = parse_paper_info(arxiv_response)\n",
|
||||
"\n",
|
||||
"if paper_info:\n",
|
||||
" print(f\"Title: {paper_info['title']}\")\n",
|
||||
" print(f\"Authors: {', '.join(paper_info['authors'])}\")\n",
|
||||
" print(f\"Published: {paper_info['published']}\")\n",
|
||||
" print(f\"Updated: {paper_info['updated']}\")\n",
|
||||
" print(f\"Abstract: {paper_info['summary']}\")\n",
|
||||
" print(f\"URL: {paper_info['url']}\")\n",
|
||||
"gpt4_paper = find_gpt4_paper()\n",
|
||||
"if gpt4_paper:\n",
|
||||
" print(\"Title:\", gpt4_paper[\"title\"])\n",
|
||||
" print(\"Summary:\", gpt4_paper[\"summary\"])\n",
|
||||
"else:\n",
|
||||
" print(\"No papers about GPT-4 were found on arxiv.\")\n",
|
||||
" print(\"No recent GPT-4 papers found.\")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"Once we have the paper details, I'll analyze the summary to identify potential applications in software development.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
|
||||
"\u001b[33mHuman\u001b[0m (to chat_manager):\n",
|
||||
"\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"exitcode: 0 (execution succeeded)\n",
|
||||
"Code output: \n",
|
||||
"Title: Breaking the Bank with ChatGPT: Few-Shot Text Classification for Finance\n",
|
||||
"Authors: \n",
|
||||
"Lefteris Loukas\n",
|
||||
", \n",
|
||||
"Ilias Stogiannidis\n",
|
||||
", \n",
|
||||
"Prodromos Malakasiotis\n",
|
||||
", \n",
|
||||
"Stavros Vassos\n",
|
||||
"\n",
|
||||
"Published: 2023-08-28T15:04:16Z\n",
|
||||
"Updated: 2023-08-28T15:04:16Z\n",
|
||||
"Abstract: We propose the use of conversational GPT models for easy and quick few-shot\n",
|
||||
"text classification in the financial domain using the Banking77 dataset. Our\n",
|
||||
"approach involves in-context learning with GPT-3.5 and GPT-4, which minimizes\n",
|
||||
"the technical expertise required and eliminates the need for expensive GPU\n",
|
||||
"computing while yielding quick and accurate results. Additionally, we fine-tune\n",
|
||||
"other pre-trained, masked language models with SetFit, a recent contrastive\n",
|
||||
"learning technique, to achieve state-of-the-art results both in full-data and\n",
|
||||
"few-shot settings. Our findings show that querying GPT-3.5 and GPT-4 can\n",
|
||||
"outperform fine-tuned, non-generative models even with fewer examples. However,\n",
|
||||
"subscription fees associated with these solutions may be considered costly for\n",
|
||||
"small organizations. Lastly, we find that generative models perform better on\n",
|
||||
"the given task when shown representative samples selected by a human expert\n",
|
||||
"rather than when shown random ones. We conclude that a) our proposed methods\n",
|
||||
"offer a practical solution for few-shot tasks in datasets with limited label\n",
|
||||
"availability, and b) our state-of-the-art results can inspire future work in\n",
|
||||
"the area.\n",
|
||||
"URL: http://arxiv.org/abs/2308.14634v1\n",
|
||||
"Title: FIMO: A Challenge Formal Dataset for Automated Theorem Proving\n",
|
||||
"Summary: We present FIMO, an innovative dataset comprising formal mathematical problem\n",
|
||||
"statements sourced from the International Mathematical Olympiad (IMO)\n",
|
||||
"Shortlisted Problems. Designed to facilitate advanced automated theorem proving\n",
|
||||
"at the IMO level, FIMO is currently tailored for the Lean formal language. It\n",
|
||||
"comprises 149 formal problem statements, accompanied by both informal problem\n",
|
||||
"descriptions and their corresponding LaTeX-based informal proofs. Through\n",
|
||||
"initial experiments involving GPT-4, our findings underscore the existing\n",
|
||||
"limitations in current methodologies, indicating a substantial journey ahead\n",
|
||||
"before achieving satisfactory IMO-level automated theorem proving outcomes.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mBob\u001b[0m (to chat_manager):\n",
|
||||
"\u001b[33mProduct_manager\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"The latest paper about GPT-4 on arxiv is titled \"Breaking the Bank with ChatGPT: Few-Shot Text Classification for Finance\" by Lefteris Loukas, Ilias Stogiannidis, Prodromos Malakasiotis, and Stavros Vassos. It was published on 2023-08-28.\n",
|
||||
"Based on the paper titled \"FIMO: A Challenge Formal Dataset for Automated Theorem Proving\" and its summary, the potential applications of GPT-4 in software development can be related to the field of automated theorem proving.\n",
|
||||
"\n",
|
||||
"The potential application of GPT-4 in this paper is for few-shot text classification in the financial domain using the Banking77 dataset. The authors propose using conversational GPT models like GPT-3.5 and GPT-4 for in-context learning, which minimizes the technical expertise required and eliminates the need for expensive GPU computing while yielding quick and accurate results.\n",
|
||||
"1. **Automated theorem proving**: GPT-4 can be utilized in the development of automated theorem proving software that attempts to prove complex mathematical problems taken from International Mathematical Olympiad (IMO) or other challenging sources. By fine-tuning GPT-4 with a dataset like FIMO consisting of formal mathematical problems, the model can potentially better understand the problem statements and generate appropriate proofs.\n",
|
||||
"\n",
|
||||
"Additionally, the paper explores fine-tuning other pre-trained, masked language models with SetFit, a recent contrastive learning technique, to achieve state-of-the-art results in both full-data and few-shot settings.\n",
|
||||
"2. **Mathematical problem-solving assistants**: Software tools can be developed using GPT-4 to guide users in solving complex mathematical problems. The AI model can be integrated into educational platforms, online math tutoring services, or even standalone tools to help make solving problems easier and faster for students and professionals alike.\n",
|
||||
"\n",
|
||||
"The findings of this paper show that querying GPT-3.5 and GPT-4 can outperform fine-tuned, non-generative models even with fewer examples. However, subscription fees associated with these solutions may be considered costly for small organizations. The authors also find that generative models perform better on the given task when shown representative samples selected by a human expert rather than when shown random ones. The proposed methods offer a practical solution for few-shot tasks in datasets with limited label availability, and the state-of-the-art results can inspire future work in the area.\n",
|
||||
"3. **Formal language translation**: GPT-4 can potentially be integrated into software for translating between formal languages, assisting in the understanding and comparison of various formal systems. This would be especially useful in research communities employing different formal languages and wanting to share ideas and results.\n",
|
||||
"\n",
|
||||
"You can access the full paper [here](http://arxiv.org/abs/2308.14634v1).\n",
|
||||
"4. **Mathematical proof checking**: GPT-4 can be employed in proof-checking software to identify and correct inconsistencies. By improving the correctness of proofs, this application would ultimately help users save time and contribute to the overall quality of mathematical research.\n",
|
||||
"\n",
|
||||
"Please note that this paper highlights the current limitations of GPT-4 in the context of IMO-level theorem proving. Nevertheless, these potential applications suggest directions for further research and software development as the model and related techniques continue to improve.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
|
||||
"\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
|
||||
"\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mCoder\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"TERMINATE\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"human.initiate_chat(manager, message=\"Find a latest paper about gpt-4 on arxiv and find its potential application.\")\n",
|
||||
"user_proxy.initiate_chat(manager, message=\"Find a latest paper about gpt-4 on arxiv and find its potential applications in software.\")\n",
|
||||
"# type exit to terminate the chat"
|
||||
]
|
||||
}
|
||||
|
||||
566
notebook/autogen_agentchat_groupchat_research.ipynb
Normal file
566
notebook/autogen_agentchat_groupchat_research.ipynb
Normal file
@@ -0,0 +1,566 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<a href=\"https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/autogen_agentchat_groupchat_research.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Auto Generated Agent Chat: Performs Research with Multi-Agent Group Chat\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"## Requirements\n",
|
||||
"\n",
|
||||
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the [autogen] option:\n",
|
||||
"```bash\n",
|
||||
"pip install flaml[autogen]\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%capture --no-stderr\n",
|
||||
"# %pip install flaml[autogen]~=2.0.3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Set your API Endpoint\n",
|
||||
"\n",
|
||||
"The [`config_list_from_json`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from flaml import autogen\n",
|
||||
"\n",
|
||||
"config_list_gpt4 = autogen.config_list_from_json(\n",
|
||||
" \"OAI_CONFIG_LIST\",\n",
|
||||
" filter_dict={\n",
|
||||
" \"model\": [\"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n",
|
||||
" },\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"It first looks for environment variable \"OAI_CONFIG_LIST\" which needs to be a valid json string. If that variable is not found, it then looks for a json file named \"OAI_CONFIG_LIST\". It filters the configs by models (you can filter by other keys as well). Only the gpt-4-32k models are kept in the list based on the filter condition.\n",
|
||||
"\n",
|
||||
"The config list looks like the following:\n",
|
||||
"```python\n",
|
||||
"config_list = [\n",
|
||||
" {\n",
|
||||
" 'model': 'gpt-4-32k',\n",
|
||||
" 'api_key': '<your OpenAI API key here>',\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" 'model': 'gpt-4-32k',\n",
|
||||
" 'api_key': '<your Azure OpenAI API key here>',\n",
|
||||
" 'api_base': '<your Azure OpenAI API base here>',\n",
|
||||
" 'api_type': 'azure',\n",
|
||||
" 'api_version': '2023-06-01-preview',\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" 'model': 'gpt-4-32k-0314',\n",
|
||||
" 'api_key': '<your Azure OpenAI API key here>',\n",
|
||||
" 'api_base': '<your Azure OpenAI API base here>',\n",
|
||||
" 'api_type': 'azure',\n",
|
||||
" 'api_version': '2023-06-01-preview',\n",
|
||||
" },\n",
|
||||
"]\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"If you open this notebook in colab, you can upload your files by clicking the file icon on the left panel and then choose \"upload file\" icon.\n",
|
||||
"\n",
|
||||
"You can set the value of config_list in other ways you prefer, e.g., loading from a YAML file."
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Construct Agents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"gpt4_config = {\n",
|
||||
" \"seed\": 42, # change the seed for different trials\n",
|
||||
" \"temperature\": 0,\n",
|
||||
" \"config_list\": config_list_gpt4,\n",
|
||||
" \"request_timeout\": 120,\n",
|
||||
"}\n",
|
||||
"user_proxy = autogen.UserProxyAgent(\n",
|
||||
" name=\"Admin\",\n",
|
||||
" system_message=\"A human admin. Interact with the planner to discuss the plan. Plan execution needs to be approved by this admin.\",\n",
|
||||
" code_execution_config=False,\n",
|
||||
")\n",
|
||||
"engineer = autogen.AssistantAgent(\n",
|
||||
" name=\"Engineer\",\n",
|
||||
" llm_config=gpt4_config,\n",
|
||||
" system_message='''Engineer. You follow an approved plan. You write python/shell code to solve tasks. Wrap the code in a code block that specifies the script type. The user can't modify your code. So do not suggest incomplete code which requires others to modify. Don't use a code block if it's not intended to be executed by the executor.\n",
|
||||
"Don't include multiple code blocks in one response. Do not ask others to copy and paste the result. Check the execution result returned by the executor.\n",
|
||||
"If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\n",
|
||||
"''',\n",
|
||||
")\n",
|
||||
"scientist = autogen.AssistantAgent(\n",
|
||||
" name=\"Scientist\",\n",
|
||||
" llm_config=gpt4_config,\n",
|
||||
" system_message=\"\"\"Scientist. You follow an approved plan. You are able to categorize papers after seeing their abstracts printed. You don't write code.\"\"\"\n",
|
||||
")\n",
|
||||
"planner = autogen.AssistantAgent(\n",
|
||||
" name=\"Planner\",\n",
|
||||
" system_message='''Planner. Suggest a plan. Revise the plan based on feedback from admin and critic, until admin approval.\n",
|
||||
"The plan may involve an engineer who can write code and a scientist who doesn't write code.\n",
|
||||
"Explain the plan first. Be clear which step is performed by an engineer, and which step is performed by a scientist.\n",
|
||||
"''',\n",
|
||||
" llm_config=gpt4_config,\n",
|
||||
")\n",
|
||||
"executor = autogen.UserProxyAgent(\n",
|
||||
" name=\"Executor\",\n",
|
||||
" system_message=\"Executor. Execute the code written by the engineer and report the result.\",\n",
|
||||
" human_input_mode=\"NEVER\",\n",
|
||||
" code_execution_config={\"last_n_messages\": 3, \"work_dir\": \"paper\"},\n",
|
||||
")\n",
|
||||
"critic = autogen.AssistantAgent(\n",
|
||||
" name=\"Critic\",\n",
|
||||
" system_message=\"Critic. Double check plan, claims, code from other agents and provide feedback. Check whether the plan includes adding verifiable info such as source URL.\",\n",
|
||||
" llm_config=gpt4_config,\n",
|
||||
")\n",
|
||||
"groupchat = autogen.GroupChat(agents=[user_proxy, engineer, scientist, planner, executor, critic], messages=[], max_round=50)\n",
|
||||
"manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=gpt4_config)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Start Chat"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[33mAdmin\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mPlanner\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"Plan:\n",
|
||||
"\n",
|
||||
"1. Engineer: Write a script to scrape the arXiv website for papers related to LLM (Language Model) applications published in the last week. The script should extract the title, authors, abstract, and link to the paper.\n",
|
||||
"\n",
|
||||
"2. Scientist: Review the scraped data to identify the different domains in which LLM is applied. This could be based on keywords in the title or abstract, or the scientist's knowledge of the field.\n",
|
||||
"\n",
|
||||
"3. Engineer: Modify the script to categorize the papers based on the domains identified by the scientist. The script should output a markdown table with columns for the domain, title, authors, abstract, and link.\n",
|
||||
"\n",
|
||||
"4. Scientist: Review the markdown table to ensure the papers are correctly categorized and the information is accurate.\n",
|
||||
"\n",
|
||||
"5. Engineer: Make any necessary revisions to the script based on the scientist's feedback.\n",
|
||||
"\n",
|
||||
"6. Scientist: Give final approval of the markdown table.\n",
|
||||
"\n",
|
||||
"7. Engineer: Submit the final markdown table.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mCritic\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"The plan seems solid and well-structured. However, it lacks the inclusion of verifiable information such as source URLs. Here's a revised version:\n",
|
||||
"\n",
|
||||
"1. Engineer: Write a script to scrape the arXiv website for papers related to LLM (Language Model) applications published in the last week. The script should extract the title, authors, abstract, and link to the paper.\n",
|
||||
"\n",
|
||||
"2. Scientist: Review the scraped data to identify the different domains in which LLM is applied. This could be based on keywords in the title or abstract, or the scientist's knowledge of the field.\n",
|
||||
"\n",
|
||||
"3. Engineer: Modify the script to categorize the papers based on the domains identified by the scientist. The script should output a markdown table with columns for the domain, title, authors, abstract, and link (source URL).\n",
|
||||
"\n",
|
||||
"4. Scientist: Review the markdown table to ensure the papers are correctly categorized and the information is accurate. Check the source URLs to verify the information.\n",
|
||||
"\n",
|
||||
"5. Engineer: Make any necessary revisions to the script based on the scientist's feedback.\n",
|
||||
"\n",
|
||||
"6. Scientist: Give final approval of the markdown table, ensuring all entries have a valid source URL.\n",
|
||||
"\n",
|
||||
"7. Engineer: Submit the final markdown table.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
|
||||
"\u001b[33mAdmin\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mEngineer\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"I'm sorry for the confusion, but as an AI model developed by OpenAI, I don't have the ability to directly scrape websites or access real-time data from external databases or websites, including arXiv. However, I can help you write a Python script that uses the arXiv API to fetch the data you need.\n",
|
||||
"\n",
|
||||
"Here's a Python script that uses the `arxiv` package to search for papers related to \"LLM applications\" from the last week. This script will print out the title, authors, summary, and URL of each paper.\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"import arxiv\n",
|
||||
"import datetime\n",
|
||||
"\n",
|
||||
"# Calculate the date one week ago\n",
|
||||
"one_week_ago = (datetime.datetime.now() - datetime.timedelta(days=7)).strftime('%Y%m%d%H%M%S')\n",
|
||||
"\n",
|
||||
"# Search for papers on LLM applications\n",
|
||||
"search = arxiv.Search(\n",
|
||||
" query=\"LLM applications\",\n",
|
||||
" max_results=100,\n",
|
||||
" sort_by=arxiv.SortCriterion.SubmittedDate,\n",
|
||||
" sort_order=arxiv.SortOrder.Descending\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"for result in search.get():\n",
|
||||
" # Check if the paper was submitted in the last week\n",
|
||||
" if result.submitted.strftime('%Y%m%d%H%M%S') > one_week_ago:\n",
|
||||
" print(f\"Title: {result.title}\")\n",
|
||||
" print(f\"Authors: {', '.join(author.name for author in result.authors)}\")\n",
|
||||
" print(f\"Summary: {result.summary}\")\n",
|
||||
" print(f\"URL: {result.entry_id}\")\n",
|
||||
" print(\"\\n\")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"You can install the `arxiv` package using pip:\n",
|
||||
"\n",
|
||||
"```shell\n",
|
||||
"pip install arxiv\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"Please note that you'll need to replace `\"LLM applications\"` with the actual search term you're interested in. The arXiv API doesn't support searching by the submission date, so the script fetches the 100 most recent results and filters them manually. You may need to increase `max_results` if there are more than 100 papers submitted per week on your topic.\n",
|
||||
"\n",
|
||||
"To create a markdown table, you'll need to format the output like this:\n",
|
||||
"\n",
|
||||
"```markdown\n",
|
||||
"| Title | Authors | Summary | URL |\n",
|
||||
"|-------|---------|---------|-----|\n",
|
||||
"| ... | ... | ... | ... |\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"You can do this in Python using f-strings:\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"print(\"| Title | Authors | Summary | URL |\")\n",
|
||||
"print(\"|-------|---------|---------|-----|\")\n",
|
||||
"for result in search.get():\n",
|
||||
" # Check if the paper was submitted in the last week\n",
|
||||
" if result.submitted.strftime('%Y%m%d%H%M%S') > one_week_ago:\n",
|
||||
" print(f\"| {result.title} | {', '.join(author.name for author in result.authors)} | {result.summary} | {result.entry_id} |\")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"This will print a markdown table to the console. If you want to write the table to a file, you can open a file and use the `write` method instead of `print`.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
|
||||
"\u001b[33mExecutor\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"exitcode: 1 (execution failed)\n",
|
||||
"Code output: \n",
|
||||
":15: DeprecationWarning: The 'get' method is deprecated, use 'results' instead\n",
|
||||
" for result in search.get():\n",
|
||||
"Traceback (most recent call last):\n",
|
||||
" File \"\", line 17, in <module>\n",
|
||||
" if result.submitted.strftime('%Y%m%d%H%M%S') > one_week_ago:\n",
|
||||
"AttributeError: 'Result' object has no attribute 'submitted'\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mEngineer\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"I apologize for the confusion. It seems there was a mistake in the code. The `arxiv` package's `Result` object doesn't have a `submitted` attribute. Instead, we should use the `published` attribute to get the date when the paper was published.\n",
|
||||
"\n",
|
||||
"Here's the corrected code:\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"import arxiv\n",
|
||||
"import datetime\n",
|
||||
"\n",
|
||||
"# Calculate the date one week ago\n",
|
||||
"one_week_ago = (datetime.datetime.now() - datetime.timedelta(days=7)).strftime('%Y%m%d%H%M%S')\n",
|
||||
"\n",
|
||||
"# Search for papers on LLM applications\n",
|
||||
"search = arxiv.Search(\n",
|
||||
" query=\"LLM applications\",\n",
|
||||
" max_results=100,\n",
|
||||
" sort_by=arxiv.SortCriterion.Relevance,\n",
|
||||
" sort_order=arxiv.SortOrder.Descending\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(\"| Title | Authors | Summary | URL |\")\n",
|
||||
"print(\"|-------|---------|---------|-----|\")\n",
|
||||
"for result in search.results():\n",
|
||||
" # Check if the paper was published in the last week\n",
|
||||
" if result.published.strftime('%Y%m%d%H%M%S') > one_week_ago:\n",
|
||||
" print(f\"| {result.title} | {', '.join(author.name for author in result.authors)} | {result.summary} | {result.entry_id} |\")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"This script will print a markdown table of papers related to \"LLM applications\" that were published in the last week. The table includes the title, authors, summary, and URL of each paper.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
|
||||
"\u001b[33mExecutor\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"exitcode: 0 (execution succeeded)\n",
|
||||
"Code output: \n",
|
||||
"| Title | Authors | Summary | URL |\n",
|
||||
"|-------|---------|---------|-----|\n",
|
||||
"| Large Language Models as Data Preprocessors | Haochen Zhang, Yuyang Dong, Chuan Xiao, Masafumi Oyamada | Large Language Models (LLMs), typified by OpenAI's GPT series and Meta's\n",
|
||||
"LLaMA variants, have marked a significant advancement in artificial\n",
|
||||
"intelligence. Trained on vast amounts of text data, LLMs are capable of\n",
|
||||
"understanding and generating human-like text across a diverse range of topics.\n",
|
||||
"This study expands on the applications of LLMs, exploring their potential in\n",
|
||||
"data preprocessing, a critical stage in data mining and analytics applications.\n",
|
||||
"We delve into the applicability of state-of-the-art LLMs such as GPT-3.5,\n",
|
||||
"GPT-4, and Vicuna-13B for error detection, data imputation, schema matching,\n",
|
||||
"and entity matching tasks. Alongside showcasing the inherent capabilities of\n",
|
||||
"LLMs, we highlight their limitations, particularly in terms of computational\n",
|
||||
"expense and inefficiency. We propose an LLM-based framework for data\n",
|
||||
"preprocessing, which integrates cutting-edge prompt engineering techniques,\n",
|
||||
"coupled with traditional methods like contextualization and feature selection,\n",
|
||||
"to improve the performance and efficiency of these models. The effectiveness of\n",
|
||||
"LLMs in data preprocessing is evaluated through an experimental study spanning\n",
|
||||
"12 datasets. GPT-4 emerged as a standout, achieving 100\\% accuracy or F1 score\n",
|
||||
"on 4 datasets, suggesting LLMs' immense potential in these tasks. Despite\n",
|
||||
"certain limitations, our study underscores the promise of LLMs in this domain\n",
|
||||
"and anticipates future developments to overcome current hurdles. | http://arxiv.org/abs/2308.16361v1 |\n",
|
||||
"| Large language models in medicine: the potentials and pitfalls | Jesutofunmi A. Omiye, Haiwen Gui, Shawheen J. Rezaei, James Zou, Roxana Daneshjou | Large language models (LLMs) have been applied to tasks in healthcare,\n",
|
||||
"ranging from medical exam questions to responding to patient questions. With\n",
|
||||
"increasing institutional partnerships between companies producing LLMs and\n",
|
||||
"healthcare systems, real world clinical application is coming closer to\n",
|
||||
"reality. As these models gain traction, it is essential for healthcare\n",
|
||||
"practitioners to understand what LLMs are, their development, their current and\n",
|
||||
"potential applications, and the associated pitfalls when utilized in medicine.\n",
|
||||
"This review and accompanying tutorial aim to give an overview of these topics\n",
|
||||
"to aid healthcare practitioners in understanding the rapidly changing landscape\n",
|
||||
"of LLMs as applied to medicine. | http://arxiv.org/abs/2309.00087v1 |\n",
|
||||
"| Point-Bind & Point-LLM: Aligning Point Cloud with Multi-modality for 3D Understanding, Generation, and Instruction Following | Ziyu Guo, Renrui Zhang, Xiangyang Zhu, Yiwen Tang, Xianzheng Ma, Jiaming Han, Kexin Chen, Peng Gao, Xianzhi Li, Hongsheng Li, Pheng-Ann Heng | We introduce Point-Bind, a 3D multi-modality model aligning point clouds with\n",
|
||||
"2D image, language, audio, and video. Guided by ImageBind, we construct a joint\n",
|
||||
"embedding space between 3D and multi-modalities, enabling many promising\n",
|
||||
"applications, e.g., any-to-3D generation, 3D embedding arithmetic, and 3D\n",
|
||||
"open-world understanding. On top of this, we further present Point-LLM, the\n",
|
||||
"first 3D large language model (LLM) following 3D multi-modal instructions. By\n",
|
||||
"parameter-efficient fine-tuning techniques, Point-LLM injects the semantics of\n",
|
||||
"Point-Bind into pre-trained LLMs, e.g., LLaMA, which requires no 3D instruction\n",
|
||||
"data, but exhibits superior 3D and multi-modal question-answering capacity. We\n",
|
||||
"hope our work may cast a light on the community for extending 3D point clouds\n",
|
||||
"to multi-modality applications. Code is available at\n",
|
||||
"https://github.com/ZiyuGuo99/Point-Bind_Point-LLM. | http://arxiv.org/abs/2309.00615v1 |\n",
|
||||
"| Where Would I Go Next? Large Language Models as Human Mobility Predictors | Xinglei Wang, Meng Fang, Zichao Zeng, Tao Cheng | Accurate human mobility prediction underpins many important applications\n",
|
||||
"across a variety of domains, including epidemic modelling, transport planning,\n",
|
||||
"and emergency responses. Due to the sparsity of mobility data and the\n",
|
||||
"stochastic nature of people's daily activities, achieving precise predictions\n",
|
||||
"of people's locations remains a challenge. While recently developed large\n",
|
||||
"language models (LLMs) have demonstrated superior performance across numerous\n",
|
||||
"language-related tasks, their applicability to human mobility studies remains\n",
|
||||
"unexplored. Addressing this gap, this article delves into the potential of LLMs\n",
|
||||
"for human mobility prediction tasks. We introduce a novel method, LLM-Mob,\n",
|
||||
"which leverages the language understanding and reasoning capabilities of LLMs\n",
|
||||
"for analysing human mobility data. We present concepts of historical stays and\n",
|
||||
"context stays to capture both long-term and short-term dependencies in human\n",
|
||||
"movement and enable time-aware prediction by using time information of the\n",
|
||||
"prediction target. Additionally, we design context-inclusive prompts that\n",
|
||||
"enable LLMs to generate more accurate predictions. Comprehensive evaluations of\n",
|
||||
"our method reveal that LLM-Mob excels in providing accurate and interpretable\n",
|
||||
"predictions, highlighting the untapped potential of LLMs in advancing human\n",
|
||||
"mobility prediction techniques. We posit that our research marks a significant\n",
|
||||
"paradigm shift in human mobility modelling, transitioning from building complex\n",
|
||||
"domain-specific models to harnessing general-purpose LLMs that yield accurate\n",
|
||||
"predictions through language instructions. The code for this work is available\n",
|
||||
"at https://github.com/xlwang233/LLM-Mob. | http://arxiv.org/abs/2308.15197v1 |\n",
|
||||
"| Interactively Robot Action Planning with Uncertainty Analysis and Active Questioning by Large Language Model | Kazuki Hori, Kanata Suzuki, Tetsuya Ogata | The application of the Large Language Model (LLM) to robot action planning\n",
|
||||
"has been actively studied. The instructions given to the LLM by natural\n",
|
||||
"language may include ambiguity and lack of information depending on the task\n",
|
||||
"context. It is possible to adjust the output of LLM by making the instruction\n",
|
||||
"input more detailed; however, the design cost is high. In this paper, we\n",
|
||||
"propose the interactive robot action planning method that allows the LLM to\n",
|
||||
"analyze and gather missing information by asking questions to humans. The\n",
|
||||
"method can minimize the design cost of generating precise robot instructions.\n",
|
||||
"We demonstrated the effectiveness of our method through concrete examples in\n",
|
||||
"cooking tasks. However, our experiments also revealed challenges in robot\n",
|
||||
"action planning with LLM, such as asking unimportant questions and assuming\n",
|
||||
"crucial information without asking. Shedding light on these issues provides\n",
|
||||
"valuable insights for future research on utilizing LLM for robotics. | http://arxiv.org/abs/2308.15684v1 |\n",
|
||||
"| AskIt: Unified Programming Interface for Programming with Large Language Models | Katsumi Okuda, Saman Amarasinghe | In the evolving landscape of software development, Large Language Models\n",
|
||||
"(LLMs) exhibit a unique phenomenon known as emergent abilities, demonstrating\n",
|
||||
"adeptness across numerous tasks, from text summarization to code generation.\n",
|
||||
"While these abilities open up novel avenues in software design and crafting,\n",
|
||||
"their incorporation presents substantial challenges. Developers grapple with\n",
|
||||
"decisions surrounding the direct embedding of LLMs within applications versus\n",
|
||||
"employing them for code generation. Moreover, effective prompt design becomes a\n",
|
||||
"critical concern, given the necessity of data extraction from natural language\n",
|
||||
"outputs. To address these intricacies, this paper introduces AskIt, a\n",
|
||||
"domain-specific language (DSL) specifically designed for LLMs. AskIt simplifies\n",
|
||||
"LLM integration, offering type-guided output control, template-based function\n",
|
||||
"definitions, and a unified interface that diminishes the distinction between\n",
|
||||
"LLM-based code generation and application integration. Furthermore, through\n",
|
||||
"Programming by Example (PBE), AskIt harnesses the power of few-shot learning at\n",
|
||||
"the programming language level. Our evaluations underscore AskIt's potency.\n",
|
||||
"Across 50 tasks, AskIt generated concise prompts for the given tasks, achieving\n",
|
||||
"a 16.14% reduction in prompt length relative to benchmarks. Additionally, by\n",
|
||||
"enabling the transition from direct LLM application usage to function\n",
|
||||
"generation, AskIt achieved significant speedups, as observed in our GSM8K\n",
|
||||
"benchmark experiments. Through these advancements, AskIt streamlines the\n",
|
||||
"integration of LLMs in software development, offering a more efficient,\n",
|
||||
"versatile approach for leveraging emergent abilities. The implementations of\n",
|
||||
"AskIt in TypeScript and Python are available at\n",
|
||||
"https://github.com/katsumiok/ts-askit and https://github.com/katsumiok/pyaskit,\n",
|
||||
"respectively. | http://arxiv.org/abs/2308.15645v1 |\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mScientist\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"Here are the papers related to LLM applications published in the last week:\n",
|
||||
"\n",
|
||||
"| Domain | Title | Authors | Summary | URL |\n",
|
||||
"|-------|---------|---------|-----|-----|\n",
|
||||
"| Data Preprocessing | [Large Language Models as Data Preprocessors](http://arxiv.org/abs/2308.16361v1) | Haochen Zhang, Yuyang Dong, Chuan Xiao, Masafumi Oyamada | This study expands on the applications of LLMs, exploring their potential in data preprocessing, a critical stage in data mining and analytics applications. | [Link](http://arxiv.org/abs/2308.16361v1) |\n",
|
||||
"| Medicine | [Large language models in medicine: the potentials and pitfalls](http://arxiv.org/abs/2309.00087v1) | Jesutofunmi A. Omiye, Haiwen Gui, Shawheen J. Rezaei, James Zou, Roxana Daneshjou | This review and accompanying tutorial aim to give an overview of these topics to aid healthcare practitioners in understanding the rapidly changing landscape of LLMs as applied to medicine. | [Link](http://arxiv.org/abs/2309.00087v1) |\n",
|
||||
"| 3D Understanding, Generation, and Instruction Following | [Point-Bind & Point-LLM: Aligning Point Cloud with Multi-modality for 3D Understanding, Generation, and Instruction Following](http://arxiv.org/abs/2309.00615v1) | Ziyu Guo, Renrui Zhang, Xiangyang Zhu, Yiwen Tang, Xianzheng Ma, Jiaming Han, Kexin Chen, Peng Gao, Xianzhi Li, Hongsheng Li, Pheng-Ann Heng | We introduce Point-Bind, a 3D multi-modality model aligning point clouds with 2D image, language, audio, and video. | [Link](http://arxiv.org/abs/2309.00615v1) |\n",
|
||||
"| Human Mobility Prediction | [Where Would I Go Next? Large Language Models as Human Mobility Predictors](http://arxiv.org/abs/2308.15197v1) | Xinglei Wang, Meng Fang, Zichao Zeng, Tao Cheng | This article delves into the potential of LLMs for human mobility prediction tasks. | [Link](http://arxiv.org/abs/2308.15197v1) |\n",
|
||||
"| Robotics | [Interactively Robot Action Planning with Uncertainty Analysis and Active Questioning by Large Language Model](http://arxiv.org/abs/2308.15684v1) | Kazuki Hori, Kanata Suzuki, Tetsuya Ogata | In this paper, we propose the interactive robot action planning method that allows the LLM to analyze and gather missing information by asking questions to humans. | [Link](http://arxiv.org/abs/2308.15684v1) |\n",
|
||||
"| Software Development | [AskIt: Unified Programming Interface for Programming with Large Language Models](http://arxiv.org/abs/2308.15645v1) | Katsumi Okuda, Saman Amarasinghe | This paper introduces AskIt, a domain-specific language (DSL) specifically designed for LLMs. | [Link](http://arxiv.org/abs/2308.15645v1) |\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mCritic\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"The scientist has done a good job categorizing the papers into different domains and providing a summary for each. The markdown table is correctly formatted and includes the source URL for each paper, which allows for verification of the information. The domains identified are diverse, indicating a broad range of applications for Large Language Models (LLMs). This review and categorization should provide a useful resource for anyone interested in the recent applications of LLMs.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"user_proxy.initiate_chat(\n",
|
||||
" manager,\n",
|
||||
" message=\"\"\"\n",
|
||||
"find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n",
|
||||
"\"\"\",\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Create Group Chat without Critic for Comparison"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[33mAdmin\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33mPlanner\u001b[0m (to chat_manager):\n",
|
||||
"\n",
|
||||
"Plan:\n",
|
||||
"\n",
|
||||
"1. Engineer: Write a script to scrape the arXiv website for papers related to LLM (Language Model) applications published in the last week. The script should extract the title, authors, abstract, and link to the paper.\n",
|
||||
"\n",
|
||||
"2. Scientist: Review the scraped data to identify the different domains in which LLM is applied. This could be based on keywords in the title or abstract, or the scientist's knowledge of the field.\n",
|
||||
"\n",
|
||||
"3. Engineer: Modify the script to categorize the papers based on the domains identified by the scientist. The script should output a markdown table with columns for the domain, title, authors, abstract, and link.\n",
|
||||
"\n",
|
||||
"4. Scientist: Review the markdown table to ensure the papers are correctly categorized and the information is accurate.\n",
|
||||
"\n",
|
||||
"5. Engineer: Make any necessary revisions to the script based on the scientist's feedback.\n",
|
||||
"\n",
|
||||
"6. Scientist: Give final approval of the markdown table.\n",
|
||||
"\n",
|
||||
"7. Engineer: Submit the final markdown table.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"groupchat_nocritic = autogen.GroupChat(agents=[user_proxy, engineer, scientist, planner, executor], messages=[], max_round=50)\n",
|
||||
"for agent in groupchat.agents:\n",
|
||||
" agent.reset()\n",
|
||||
"manager_nocritic = autogen.GroupChatManager(groupchat=groupchat_nocritic, llm_config=gpt4_config)\n",
|
||||
"user_proxy.initiate_chat(\n",
|
||||
" manager_nocritic,\n",
|
||||
" message=\"\"\"\n",
|
||||
"find papers on LLM applications from arxiv in the last week, create a markdown table of different domains.\n",
|
||||
"\"\"\",\n",
|
||||
")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "flaml",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.17"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
1038
notebook/autogen_agentchat_groupchat_vis.ipynb
Normal file
1038
notebook/autogen_agentchat_groupchat_vis.ipynb
Normal file
File diff suppressed because one or more lines are too long
@@ -20,7 +20,7 @@
|
||||
"# Auto Generated Agent Chat: Task Solving with Code Generation, Execution, Debugging & Human Feedback\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use `AssistantAgent` and `UserProxyAgent` to solve a challenging math problem with human feedback. Here `AssistantAgent` is an LLM-based agent that can write Python code (in a Python coding block) for a user to execute for a given task. `UserProxyAgent` is an agent which serves as a proxy for a user to execute the code written by `AssistantAgent`. By setting `human_input_mode` properly, the `UserProxyAgent` can also prompt the user for feedback to `AssistantAgent`. For example, when `human_input_mode` is set to \"ALWAYS\", the `UserProxyAgent` will always prompt the user for feedback. When user feedback is provided, the `UserProxyAgent` will directly pass the feedback to `AssistantAgent`. When no user feedback is provided, the `UserProxyAgent` will execute the code written by `AssistantAgent` and return the execution results (success or failure and corresponding outputs) to `AssistantAgent`.\n",
|
||||
"\n",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"# Auto Generated Agent Chat: Collaborative Task Solving with Coding and Planning Agent\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use multiple agents to work together and accomplish a task which requires finding info from the web and coding. `AssistantAgent` is an LLM-based agent that can write and debug Python code (in a Python coding block) for a user to execute for a given task. `UserProxyAgent` is an agent which serves as a proxy for a user to execute the code written by `AssistantAgent`. We further create a planning agent for the assistant agent to consult. The planning agent is a variation of the LLM-based `AssistantAgent` with a different system message.\n",
|
||||
"\n",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"# Interactive LLM Agent Dealing with Data Stream\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use customized agents to continuously acquires news from the web and ask for investment suggestions.\n",
|
||||
"\n",
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %pip install flaml[autogen]~=2.0.0"
|
||||
"# %pip install flaml[autogen]~=2.1.0"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -258,7 +258,7 @@
|
||||
" )\n",
|
||||
" return False, None\n",
|
||||
"\n",
|
||||
"user_proxy.register_auto_reply(autogen.AssistantAgent, add_data_reply, 1, config={\"news_stream\": data})"
|
||||
"user_proxy.register_reply(autogen.AssistantAgent, add_data_reply, 1, config={\"news_stream\": data})"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"source": [
|
||||
"# Auto Generated Agent Chat: Collaborative Task Solving with Multiple Agents and Human Users\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"In this notebook, we demonstrate an application involving multiple agents and human users to work together and accomplish a task. `AssistantAgent` is an LLM-based agent that can write Python code (in a Python coding block) for a user to execute for a given task. `UserProxyAgent` is an agent which serves as a proxy for a user to execute the code written by `AssistantAgent`. We create multiple `UserProxyAgent` instances which can represent different human users.\n",
|
||||
"\n",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"# Auto Generated Agent Chat: Solving Tasks Requiring Web Info\n",
|
||||
"\n",
|
||||
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
|
||||
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use `AssistantAgent` and `UserProxyAgent` to perform tasks which require acquiring info from the web:\n",
|
||||
"* discuss a paper based on its URL.\n",
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
],
|
||||
"source": [
|
||||
"from minio.error import ServerError\n",
|
||||
"from flaml.data import load_openml_dataset\n",
|
||||
"from flaml.automl.data import load_openml_dataset\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=1169, data_dir='./')\n",
|
||||
@@ -1252,7 +1252,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = \\\n",
|
||||
" get_output_from_log(filename=settings['log_file_name'], time_budget=240)\n",
|
||||
"for config in config_history:\n",
|
||||
@@ -1540,7 +1540,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"''' SKLearnEstimator is the super class for a sklearn learner '''\n",
|
||||
"from flaml.model import SKLearnEstimator\n",
|
||||
"from flaml.automl.model import SKLearnEstimator\n",
|
||||
"from flaml import tune\n",
|
||||
"from flaml.automl.task.task import CLASSIFICATION\n",
|
||||
"\n",
|
||||
|
||||
@@ -37,383 +37,20 @@
|
||||
"\n",
|
||||
"In this notebook, we use one real data example (binary classification) to showcase how to use FLAML library.\n",
|
||||
"\n",
|
||||
"FLAML requires `Python>=3.7`. To run this notebook example, please install the following packages."
|
||||
"FLAML requires `Python>=3.8`. To run this notebook example, please install the following packages."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.livy.statement-meta+json": {
|
||||
"execution_finish_time": "2023-04-09T03:11:05.782522Z",
|
||||
"execution_start_time": "2023-04-09T03:11:05.7822033Z",
|
||||
"livy_statement_state": "available",
|
||||
"parent_msg_id": "18b2ee64-09c4-4ceb-8975-e4ed43d7c41a",
|
||||
"queued_time": "2023-04-09T03:10:33.571519Z",
|
||||
"session_id": "7",
|
||||
"session_start_time": null,
|
||||
"spark_jobs": null,
|
||||
"spark_pool": null,
|
||||
"state": "finished",
|
||||
"statement_id": -1
|
||||
},
|
||||
"text/plain": [
|
||||
"StatementMeta(, 7, -1, Finished, Available)"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {},
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Collecting flaml[synapse]==1.1.3\n",
|
||||
" Using cached FLAML-1.1.3-py3-none-any.whl (224 kB)\n",
|
||||
"Collecting xgboost==1.6.1\n",
|
||||
" Using cached xgboost-1.6.1-py3-none-manylinux2014_x86_64.whl (192.9 MB)\n",
|
||||
"Collecting pandas==1.5.1\n",
|
||||
" Using cached pandas-1.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.2 MB)\n",
|
||||
"Collecting numpy==1.23.4\n",
|
||||
" Using cached numpy-1.23.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)\n",
|
||||
"Collecting openml\n",
|
||||
" Using cached openml-0.13.1-py3-none-any.whl\n",
|
||||
"Collecting scipy>=1.4.1\n",
|
||||
" Using cached scipy-1.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.5 MB)\n",
|
||||
"Collecting scikit-learn>=0.24\n",
|
||||
" Using cached scikit_learn-1.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.8 MB)\n",
|
||||
"Collecting lightgbm>=2.3.1\n",
|
||||
" Using cached lightgbm-3.3.5-py3-none-manylinux1_x86_64.whl (2.0 MB)\n",
|
||||
"Collecting pyspark>=3.0.0\n",
|
||||
" Using cached pyspark-3.3.2-py2.py3-none-any.whl\n",
|
||||
"Collecting optuna==2.8.0\n",
|
||||
" Using cached optuna-2.8.0-py3-none-any.whl (301 kB)\n",
|
||||
"Collecting joblibspark>=0.5.0\n",
|
||||
" Using cached joblibspark-0.5.1-py3-none-any.whl (15 kB)\n",
|
||||
"Collecting python-dateutil>=2.8.1\n",
|
||||
" Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)\n",
|
||||
"Collecting pytz>=2020.1\n",
|
||||
" Using cached pytz-2023.3-py2.py3-none-any.whl (502 kB)\n",
|
||||
"Collecting cliff\n",
|
||||
" Using cached cliff-4.2.0-py3-none-any.whl (81 kB)\n",
|
||||
"Collecting packaging>=20.0\n",
|
||||
" Using cached packaging-23.0-py3-none-any.whl (42 kB)\n",
|
||||
"Collecting cmaes>=0.8.2\n",
|
||||
" Using cached cmaes-0.9.1-py3-none-any.whl (21 kB)\n",
|
||||
"Collecting sqlalchemy>=1.1.0\n",
|
||||
" Using cached SQLAlchemy-2.0.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB)\n",
|
||||
"Collecting tqdm\n",
|
||||
" Using cached tqdm-4.65.0-py3-none-any.whl (77 kB)\n",
|
||||
"Collecting alembic\n",
|
||||
" Using cached alembic-1.10.3-py3-none-any.whl (212 kB)\n",
|
||||
"Collecting colorlog\n",
|
||||
" Using cached colorlog-6.7.0-py2.py3-none-any.whl (11 kB)\n",
|
||||
"Collecting xmltodict\n",
|
||||
" Using cached xmltodict-0.13.0-py2.py3-none-any.whl (10.0 kB)\n",
|
||||
"Collecting requests\n",
|
||||
" Using cached requests-2.28.2-py3-none-any.whl (62 kB)\n",
|
||||
"Collecting minio\n",
|
||||
" Using cached minio-7.1.14-py3-none-any.whl (77 kB)\n",
|
||||
"Collecting liac-arff>=2.4.0\n",
|
||||
" Using cached liac_arff-2.5.0-py3-none-any.whl\n",
|
||||
"Collecting pyarrow\n",
|
||||
" Using cached pyarrow-11.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35.0 MB)\n",
|
||||
"Collecting joblib>=0.14\n",
|
||||
" Using cached joblib-1.2.0-py3-none-any.whl (297 kB)\n",
|
||||
"Collecting wheel\n",
|
||||
" Using cached wheel-0.40.0-py3-none-any.whl (64 kB)\n",
|
||||
"Collecting py4j==0.10.9.5\n",
|
||||
" Using cached py4j-0.10.9.5-py2.py3-none-any.whl (199 kB)\n",
|
||||
"Collecting six>=1.5\n",
|
||||
" Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)\n",
|
||||
"Collecting threadpoolctl>=2.0.0\n",
|
||||
" Using cached threadpoolctl-3.1.0-py3-none-any.whl (14 kB)\n",
|
||||
"Collecting urllib3\n",
|
||||
" Using cached urllib3-1.26.15-py2.py3-none-any.whl (140 kB)\n",
|
||||
"Collecting certifi\n",
|
||||
" Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)\n",
|
||||
"Collecting idna<4,>=2.5\n",
|
||||
" Using cached idna-3.4-py3-none-any.whl (61 kB)\n",
|
||||
"Collecting charset-normalizer<4,>=2\n",
|
||||
" Using cached charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (195 kB)\n",
|
||||
"Collecting typing-extensions>=4.2.0\n",
|
||||
" Using cached typing_extensions-4.5.0-py3-none-any.whl (27 kB)\n",
|
||||
"Collecting greenlet!=0.4.17\n",
|
||||
" Using cached greenlet-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (618 kB)\n",
|
||||
"Collecting importlib-metadata\n",
|
||||
" Using cached importlib_metadata-6.2.0-py3-none-any.whl (21 kB)\n",
|
||||
"Collecting importlib-resources\n",
|
||||
" Using cached importlib_resources-5.12.0-py3-none-any.whl (36 kB)\n",
|
||||
"Collecting Mako\n",
|
||||
" Using cached Mako-1.2.4-py3-none-any.whl (78 kB)\n",
|
||||
"Collecting autopage>=0.4.0\n",
|
||||
" Using cached autopage-0.5.1-py3-none-any.whl (29 kB)\n",
|
||||
"Collecting cmd2>=1.0.0\n",
|
||||
" Using cached cmd2-2.4.3-py3-none-any.whl (147 kB)\n",
|
||||
"Collecting stevedore>=2.0.1\n",
|
||||
" Using cached stevedore-5.0.0-py3-none-any.whl (49 kB)\n",
|
||||
"Collecting PrettyTable>=0.7.2\n",
|
||||
" Using cached prettytable-3.6.0-py3-none-any.whl (27 kB)\n",
|
||||
"Collecting PyYAML>=3.12\n",
|
||||
" Using cached PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (701 kB)\n",
|
||||
"Collecting attrs>=16.3.0\n",
|
||||
" Using cached attrs-22.2.0-py3-none-any.whl (60 kB)\n",
|
||||
"Collecting pyperclip>=1.6\n",
|
||||
" Using cached pyperclip-1.8.2-py3-none-any.whl\n",
|
||||
"Collecting wcwidth>=0.1.7\n",
|
||||
" Using cached wcwidth-0.2.6-py2.py3-none-any.whl (29 kB)\n",
|
||||
"Collecting zipp>=0.5\n",
|
||||
" Using cached zipp-3.15.0-py3-none-any.whl (6.8 kB)\n",
|
||||
"Collecting pbr!=2.1.0,>=2.0.0\n",
|
||||
" Using cached pbr-5.11.1-py2.py3-none-any.whl (112 kB)\n",
|
||||
"Collecting MarkupSafe>=0.9.2\n",
|
||||
" Using cached MarkupSafe-2.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)\n",
|
||||
"Installing collected packages: wcwidth, pytz, pyperclip, py4j, zipp, xmltodict, wheel, urllib3, typing-extensions, tqdm, threadpoolctl, six, PyYAML, pyspark, PrettyTable, pbr, packaging, numpy, MarkupSafe, liac-arff, joblib, idna, greenlet, colorlog, charset-normalizer, certifi, autopage, attrs, stevedore, sqlalchemy, scipy, requests, python-dateutil, pyarrow, minio, Mako, joblibspark, importlib-resources, importlib-metadata, cmd2, cmaes, xgboost, scikit-learn, pandas, cliff, alembic, optuna, openml, lightgbm, flaml\n",
|
||||
" Attempting uninstall: wcwidth\n",
|
||||
" Found existing installation: wcwidth 0.2.6\n",
|
||||
" Uninstalling wcwidth-0.2.6:\n",
|
||||
" Successfully uninstalled wcwidth-0.2.6\n",
|
||||
" Attempting uninstall: pytz\n",
|
||||
" Found existing installation: pytz 2023.3\n",
|
||||
" Uninstalling pytz-2023.3:\n",
|
||||
" Successfully uninstalled pytz-2023.3\n",
|
||||
" Attempting uninstall: pyperclip\n",
|
||||
" Found existing installation: pyperclip 1.8.2\n",
|
||||
" Uninstalling pyperclip-1.8.2:\n",
|
||||
" Successfully uninstalled pyperclip-1.8.2\n",
|
||||
" Attempting uninstall: py4j\n",
|
||||
" Found existing installation: py4j 0.10.9.5\n",
|
||||
" Uninstalling py4j-0.10.9.5:\n",
|
||||
" Successfully uninstalled py4j-0.10.9.5\n",
|
||||
" Attempting uninstall: zipp\n",
|
||||
" Found existing installation: zipp 3.15.0\n",
|
||||
" Uninstalling zipp-3.15.0:\n",
|
||||
" Successfully uninstalled zipp-3.15.0\n",
|
||||
" Attempting uninstall: xmltodict\n",
|
||||
" Found existing installation: xmltodict 0.13.0\n",
|
||||
" Uninstalling xmltodict-0.13.0:\n",
|
||||
" Successfully uninstalled xmltodict-0.13.0\n",
|
||||
" Attempting uninstall: wheel\n",
|
||||
" Found existing installation: wheel 0.40.0\n",
|
||||
" Uninstalling wheel-0.40.0:\n",
|
||||
" Successfully uninstalled wheel-0.40.0\n",
|
||||
" Attempting uninstall: urllib3\n",
|
||||
" Found existing installation: urllib3 1.26.15\n",
|
||||
" Uninstalling urllib3-1.26.15:\n",
|
||||
" Successfully uninstalled urllib3-1.26.15\n",
|
||||
" Attempting uninstall: typing-extensions\n",
|
||||
" Found existing installation: typing_extensions 4.5.0\n",
|
||||
" Uninstalling typing_extensions-4.5.0:\n",
|
||||
" Successfully uninstalled typing_extensions-4.5.0\n",
|
||||
" Attempting uninstall: tqdm\n",
|
||||
" Found existing installation: tqdm 4.65.0\n",
|
||||
" Uninstalling tqdm-4.65.0:\n",
|
||||
" Successfully uninstalled tqdm-4.65.0\n",
|
||||
" Attempting uninstall: threadpoolctl\n",
|
||||
" Found existing installation: threadpoolctl 3.1.0\n",
|
||||
" Uninstalling threadpoolctl-3.1.0:\n",
|
||||
" Successfully uninstalled threadpoolctl-3.1.0\n",
|
||||
" Attempting uninstall: six\n",
|
||||
" Found existing installation: six 1.16.0\n",
|
||||
" Uninstalling six-1.16.0:\n",
|
||||
" Successfully uninstalled six-1.16.0\n",
|
||||
" Attempting uninstall: PyYAML\n",
|
||||
" Found existing installation: PyYAML 6.0\n",
|
||||
" Uninstalling PyYAML-6.0:\n",
|
||||
" Successfully uninstalled PyYAML-6.0\n",
|
||||
" Attempting uninstall: pyspark\n",
|
||||
" Found existing installation: pyspark 3.3.2\n",
|
||||
" Uninstalling pyspark-3.3.2:\n",
|
||||
" Successfully uninstalled pyspark-3.3.2\n",
|
||||
" Attempting uninstall: PrettyTable\n",
|
||||
" Found existing installation: prettytable 3.6.0\n",
|
||||
" Uninstalling prettytable-3.6.0:\n",
|
||||
" Successfully uninstalled prettytable-3.6.0\n",
|
||||
" Attempting uninstall: pbr\n",
|
||||
" Found existing installation: pbr 5.11.1\n",
|
||||
" Uninstalling pbr-5.11.1:\n",
|
||||
" Successfully uninstalled pbr-5.11.1\n",
|
||||
" Attempting uninstall: packaging\n",
|
||||
" Found existing installation: packaging 23.0\n",
|
||||
" Uninstalling packaging-23.0:\n",
|
||||
" Successfully uninstalled packaging-23.0\n",
|
||||
" Attempting uninstall: numpy\n",
|
||||
" Found existing installation: numpy 1.23.4\n",
|
||||
" Uninstalling numpy-1.23.4:\n",
|
||||
" Successfully uninstalled numpy-1.23.4\n",
|
||||
" Attempting uninstall: MarkupSafe\n",
|
||||
" Found existing installation: MarkupSafe 2.1.2\n",
|
||||
" Uninstalling MarkupSafe-2.1.2:\n",
|
||||
" Successfully uninstalled MarkupSafe-2.1.2\n",
|
||||
" Attempting uninstall: liac-arff\n",
|
||||
" Found existing installation: liac-arff 2.5.0\n",
|
||||
" Uninstalling liac-arff-2.5.0:\n",
|
||||
" Successfully uninstalled liac-arff-2.5.0\n",
|
||||
" Attempting uninstall: joblib\n",
|
||||
" Found existing installation: joblib 1.2.0\n",
|
||||
" Uninstalling joblib-1.2.0:\n",
|
||||
" Successfully uninstalled joblib-1.2.0\n",
|
||||
" Attempting uninstall: idna\n",
|
||||
" Found existing installation: idna 3.4\n",
|
||||
" Uninstalling idna-3.4:\n",
|
||||
" Successfully uninstalled idna-3.4\n",
|
||||
" Attempting uninstall: greenlet\n",
|
||||
" Found existing installation: greenlet 2.0.2\n",
|
||||
" Uninstalling greenlet-2.0.2:\n",
|
||||
" Successfully uninstalled greenlet-2.0.2\n",
|
||||
" Attempting uninstall: colorlog\n",
|
||||
" Found existing installation: colorlog 6.7.0\n",
|
||||
" Uninstalling colorlog-6.7.0:\n",
|
||||
" Successfully uninstalled colorlog-6.7.0\n",
|
||||
" Attempting uninstall: charset-normalizer\n",
|
||||
" Found existing installation: charset-normalizer 3.1.0\n",
|
||||
" Uninstalling charset-normalizer-3.1.0:\n",
|
||||
" Successfully uninstalled charset-normalizer-3.1.0\n",
|
||||
" Attempting uninstall: certifi\n",
|
||||
" Found existing installation: certifi 2022.12.7\n",
|
||||
" Uninstalling certifi-2022.12.7:\n",
|
||||
" Successfully uninstalled certifi-2022.12.7\n",
|
||||
" Attempting uninstall: autopage\n",
|
||||
" Found existing installation: autopage 0.5.1\n",
|
||||
" Uninstalling autopage-0.5.1:\n",
|
||||
" Successfully uninstalled autopage-0.5.1\n",
|
||||
" Attempting uninstall: attrs\n",
|
||||
" Found existing installation: attrs 22.2.0\n",
|
||||
" Uninstalling attrs-22.2.0:\n",
|
||||
" Successfully uninstalled attrs-22.2.0\n",
|
||||
" Attempting uninstall: stevedore\n",
|
||||
" Found existing installation: stevedore 5.0.0\n",
|
||||
" Uninstalling stevedore-5.0.0:\n",
|
||||
" Successfully uninstalled stevedore-5.0.0\n",
|
||||
" Attempting uninstall: sqlalchemy\n",
|
||||
" Found existing installation: SQLAlchemy 2.0.9\n",
|
||||
" Uninstalling SQLAlchemy-2.0.9:\n",
|
||||
" Successfully uninstalled SQLAlchemy-2.0.9\n",
|
||||
" Attempting uninstall: scipy\n",
|
||||
" Found existing installation: scipy 1.10.1\n",
|
||||
" Uninstalling scipy-1.10.1:\n",
|
||||
" Successfully uninstalled scipy-1.10.1\n",
|
||||
" Attempting uninstall: requests\n",
|
||||
" Found existing installation: requests 2.28.2\n",
|
||||
" Uninstalling requests-2.28.2:\n",
|
||||
" Successfully uninstalled requests-2.28.2\n",
|
||||
" Attempting uninstall: python-dateutil\n",
|
||||
" Found existing installation: python-dateutil 2.8.2\n",
|
||||
" Uninstalling python-dateutil-2.8.2:\n",
|
||||
" Successfully uninstalled python-dateutil-2.8.2\n",
|
||||
" Attempting uninstall: pyarrow\n",
|
||||
" Found existing installation: pyarrow 11.0.0\n",
|
||||
" Uninstalling pyarrow-11.0.0:\n",
|
||||
" Successfully uninstalled pyarrow-11.0.0\n",
|
||||
" Attempting uninstall: minio\n",
|
||||
" Found existing installation: minio 7.1.14\n",
|
||||
" Uninstalling minio-7.1.14:\n",
|
||||
" Successfully uninstalled minio-7.1.14\n",
|
||||
" Attempting uninstall: Mako\n",
|
||||
" Found existing installation: Mako 1.2.4\n",
|
||||
" Uninstalling Mako-1.2.4:\n",
|
||||
" Successfully uninstalled Mako-1.2.4\n",
|
||||
" Attempting uninstall: joblibspark\n",
|
||||
" Found existing installation: joblibspark 0.5.1\n",
|
||||
" Uninstalling joblibspark-0.5.1:\n",
|
||||
" Successfully uninstalled joblibspark-0.5.1\n",
|
||||
" Attempting uninstall: importlib-resources\n",
|
||||
" Found existing installation: importlib-resources 5.12.0\n",
|
||||
" Uninstalling importlib-resources-5.12.0:\n",
|
||||
" Successfully uninstalled importlib-resources-5.12.0\n",
|
||||
" Attempting uninstall: importlib-metadata\n",
|
||||
" Found existing installation: importlib-metadata 6.2.0\n",
|
||||
" Uninstalling importlib-metadata-6.2.0:\n",
|
||||
" Successfully uninstalled importlib-metadata-6.2.0\n",
|
||||
" Attempting uninstall: cmd2\n",
|
||||
" Found existing installation: cmd2 2.4.3\n",
|
||||
" Uninstalling cmd2-2.4.3:\n",
|
||||
" Successfully uninstalled cmd2-2.4.3\n",
|
||||
" Attempting uninstall: cmaes\n",
|
||||
" Found existing installation: cmaes 0.9.1\n",
|
||||
" Uninstalling cmaes-0.9.1:\n",
|
||||
" Successfully uninstalled cmaes-0.9.1\n",
|
||||
" Attempting uninstall: xgboost\n",
|
||||
" Found existing installation: xgboost 1.6.1\n",
|
||||
" Uninstalling xgboost-1.6.1:\n",
|
||||
" Successfully uninstalled xgboost-1.6.1\n",
|
||||
" Attempting uninstall: scikit-learn\n",
|
||||
" Found existing installation: scikit-learn 1.2.2\n",
|
||||
" Uninstalling scikit-learn-1.2.2:\n",
|
||||
" Successfully uninstalled scikit-learn-1.2.2\n",
|
||||
" Attempting uninstall: pandas\n",
|
||||
" Found existing installation: pandas 1.5.1\n",
|
||||
" Uninstalling pandas-1.5.1:\n",
|
||||
" Successfully uninstalled pandas-1.5.1\n",
|
||||
" Attempting uninstall: cliff\n",
|
||||
" Found existing installation: cliff 4.2.0\n",
|
||||
" Uninstalling cliff-4.2.0:\n",
|
||||
" Successfully uninstalled cliff-4.2.0\n",
|
||||
" Attempting uninstall: alembic\n",
|
||||
" Found existing installation: alembic 1.10.3\n",
|
||||
" Uninstalling alembic-1.10.3:\n",
|
||||
" Successfully uninstalled alembic-1.10.3\n",
|
||||
" Attempting uninstall: optuna\n",
|
||||
" Found existing installation: optuna 2.8.0\n",
|
||||
" Uninstalling optuna-2.8.0:\n",
|
||||
" Successfully uninstalled optuna-2.8.0\n",
|
||||
" Attempting uninstall: openml\n",
|
||||
" Found existing installation: openml 0.13.1\n",
|
||||
" Uninstalling openml-0.13.1:\n",
|
||||
" Successfully uninstalled openml-0.13.1\n",
|
||||
" Attempting uninstall: lightgbm\n",
|
||||
" Found existing installation: lightgbm 3.3.5\n",
|
||||
" Uninstalling lightgbm-3.3.5:\n",
|
||||
" Successfully uninstalled lightgbm-3.3.5\n",
|
||||
" Attempting uninstall: flaml\n",
|
||||
" Found existing installation: FLAML 1.1.3\n",
|
||||
" Uninstalling FLAML-1.1.3:\n",
|
||||
" Successfully uninstalled FLAML-1.1.3\n",
|
||||
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
|
||||
"virtualenv 20.14.0 requires platformdirs<3,>=2, but you have platformdirs 3.2.0 which is incompatible.\n",
|
||||
"tensorflow 2.4.1 requires six~=1.15.0, but you have six 1.16.0 which is incompatible.\n",
|
||||
"tensorflow 2.4.1 requires typing-extensions~=3.7.4, but you have typing-extensions 4.5.0 which is incompatible.\n",
|
||||
"pmdarima 1.8.2 requires numpy~=1.19.0, but you have numpy 1.23.4 which is incompatible.\n",
|
||||
"koalas 1.8.0 requires numpy<1.20.0,>=1.14, but you have numpy 1.23.4 which is incompatible.\n",
|
||||
"gevent 21.1.2 requires greenlet<2.0,>=0.4.17; platform_python_implementation == \"CPython\", but you have greenlet 2.0.2 which is incompatible.\n",
|
||||
"azureml-dataset-runtime 1.34.0 requires pyarrow<4.0.0,>=0.17.0, but you have pyarrow 11.0.0 which is incompatible.\n",
|
||||
"azureml-core 1.34.0 requires urllib3<=1.26.6,>=1.23, but you have urllib3 1.26.15 which is incompatible.\u001b[0m\u001b[31m\n",
|
||||
"\u001b[0mSuccessfully installed Mako-1.2.4 MarkupSafe-2.1.2 PrettyTable-3.6.0 PyYAML-6.0 alembic-1.10.3 attrs-22.2.0 autopage-0.5.1 certifi-2022.12.7 charset-normalizer-3.1.0 cliff-4.2.0 cmaes-0.9.1 cmd2-2.4.3 colorlog-6.7.0 flaml-1.1.3 greenlet-2.0.2 idna-3.4 importlib-metadata-6.2.0 importlib-resources-5.12.0 joblib-1.2.0 joblibspark-0.5.1 liac-arff-2.5.0 lightgbm-3.3.5 minio-7.1.14 numpy-1.23.4 openml-0.13.1 optuna-2.8.0 packaging-23.0 pandas-1.5.1 pbr-5.11.1 py4j-0.10.9.5 pyarrow-11.0.0 pyperclip-1.8.2 pyspark-3.3.2 python-dateutil-2.8.2 pytz-2023.3 requests-2.28.2 scikit-learn-1.2.2 scipy-1.10.1 six-1.16.0 sqlalchemy-2.0.9 stevedore-5.0.0 threadpoolctl-3.1.0 tqdm-4.65.0 typing-extensions-4.5.0 urllib3-1.26.15 wcwidth-0.2.6 wheel-0.40.0 xgboost-1.6.1 xmltodict-0.13.0 zipp-3.15.0\n",
|
||||
"\u001b[33mWARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.\n",
|
||||
"You should consider upgrading via the '/nfs4/pyenv-bfada21f-d1ed-44b9-a41d-4ff480d237e7/bin/python -m pip install --upgrade pip' command.\u001b[0m\u001b[33m\n",
|
||||
"\u001b[0mNote: you may need to restart the kernel to use updated packages.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {},
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Warning: PySpark kernel has been restarted to use updated packages.\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install flaml[synapse]==1.1.3 xgboost==1.6.1 pandas==1.5.1 numpy==1.23.4 openml --force-reinstall"
|
||||
"%pip install flaml[automl,synapse] xgboost==1.6.1 pandas==1.5.1 numpy==1.23.4 openml --force-reinstall"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -480,7 +117,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import load_openml_dataset\n",
|
||||
"from flaml.automl.data import load_openml_dataset\n",
|
||||
"X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=1169, data_dir='./')"
|
||||
]
|
||||
},
|
||||
@@ -1389,7 +1026,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = \\\n",
|
||||
" get_output_from_log(filename=settings['log_file_name'], time_budget=240)\n",
|
||||
"for config in config_history:\n",
|
||||
@@ -1861,7 +1498,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install rgf-python "
|
||||
"%pip install rgf-python "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1898,9 +1535,9 @@
|
||||
],
|
||||
"source": [
|
||||
"''' SKLearnEstimator is the super class for a sklearn learner '''\n",
|
||||
"from flaml.model import SKLearnEstimator\n",
|
||||
"from flaml.automl.model import SKLearnEstimator\n",
|
||||
"from flaml import tune\n",
|
||||
"from flaml.data import CLASSIFICATION\n",
|
||||
"from flaml.automl.data import CLASSIFICATION\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class MyRegularizedGreedyForest(SKLearnEstimator):\n",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use FLAML library to tune hyperparameters of LightGBM with a regression example.\n",
|
||||
"\n",
|
||||
"FLAML requires `Python>=3.7`. To run this notebook example, please install flaml with the `automl` option (this option is introduced from version 2, for version 1 it is installed by default):\n",
|
||||
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the `automl` option (this option is introduced from version 2, for version 1 it is installed by default):\n",
|
||||
"```bash\n",
|
||||
"pip install flaml[automl]\n",
|
||||
"```"
|
||||
@@ -87,7 +87,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import load_openml_dataset\n",
|
||||
"from flaml.automl.data import load_openml_dataset\n",
|
||||
"X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=537, data_dir='./')"
|
||||
]
|
||||
},
|
||||
@@ -509,7 +509,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = \\\n",
|
||||
" get_output_from_log(filename=settings['log_file_name'], time_budget=60)\n",
|
||||
"\n",
|
||||
@@ -852,7 +852,7 @@
|
||||
" coef[0] * hess + coef[1] * hess_rmse + coef[2] * hess_mae\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"from flaml.model import LGBMEstimator\n",
|
||||
"from flaml.automl.model import LGBMEstimator\n",
|
||||
"\n",
|
||||
"''' create a customized LightGBM learner class with your objective function '''\n",
|
||||
"class MyLGBM(LGBMEstimator):\n",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use the FLAML library to fine tune an NLP language model with hyperparameter search. We will use [flaml.tune](https://microsoft.github.io/FLAML/docs/Use-Cases/Tune-User-Defined-Function) with the built in GPU in colab for the tuning. However, if you have a machine with more than 1 GPU, you can also use FLAML's [parallel tuning](https://microsoft.github.io/FLAML/docs/Use-Cases/Task-Oriented-AutoML#parallel-tuning) with the ray tune option. \n",
|
||||
"\n",
|
||||
"FLAML requires `Python>=3.7`. To run this notebook example, please install flaml with the `[automl,hf,blendsearch]` option:\n",
|
||||
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the `[automl,hf,blendsearch]` option:\n",
|
||||
"```bash\n",
|
||||
"pip install flaml[automl,hf,blendsearch]; \n",
|
||||
"```"
|
||||
@@ -2107,7 +2107,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = \\\n",
|
||||
" get_output_from_log(filename=automl_settings['log_file_name'], time_budget=3000)\n",
|
||||
"for config in config_history:\n",
|
||||
@@ -3460,7 +3460,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
@@ -4098,7 +4098,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = \\\n",
|
||||
" get_output_from_log(filename=automl_settings['log_file_name'], time_budget=3000)\n",
|
||||
"for config in config_history:\n",
|
||||
@@ -5136,7 +5136,7 @@
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = \\\n",
|
||||
" get_output_from_log(filename=automl_settings['log_file_name'], time_budget=3000)\n",
|
||||
"for config in config_history:\n",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use FLAML library for time series forecasting tasks: univariate time series forecasting (only time), multivariate time series forecasting (with exogneous variables) and forecasting discrete values.\n",
|
||||
"\n",
|
||||
"FLAML requires Python>=3.7. To run this notebook example, please install flaml with the [automl,ts_forecast] option:\n"
|
||||
"FLAML requires Python>=3.8. To run this notebook example, please install flaml with the [automl,ts_forecast] option:\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1518,7 +1518,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, train_loss_history = \\\n",
|
||||
" get_output_from_log(filename=settings['log_file_name'], time_budget=180)\n",
|
||||
"\n",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"\n",
|
||||
"In this notebook, we demonstrate how to use FLAML library to tune hyperparameters of XGBoost with a regression example.\n",
|
||||
"\n",
|
||||
"FLAML requires `Python>=3.7`. To run this notebook example, please install flaml with the `automl` option (this option is introduced from version 2, for version 1 it is installed by default):\n",
|
||||
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the `automl` option (this option is introduced from version 2, for version 1 it is installed by default):\n",
|
||||
"```bash\n",
|
||||
"pip install flaml[automl]\n",
|
||||
"```"
|
||||
@@ -44,6 +44,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
@@ -87,11 +88,12 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import load_openml_dataset\n",
|
||||
"from flaml.automl.data import load_openml_dataset\n",
|
||||
"X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=537, data_dir='./')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
@@ -509,6 +511,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
@@ -761,7 +764,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import get_output_from_log\n",
|
||||
"from flaml.automl.data import get_output_from_log\n",
|
||||
"time_history, best_valid_loss_history, valid_loss_history, config_history, metric_history = \\\n",
|
||||
" get_output_from_log(filename=settings['log_file_name'], time_budget=60)\n",
|
||||
"\n",
|
||||
@@ -804,6 +807,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -832,6 +836,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -922,6 +927,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -1839,7 +1845,7 @@
|
||||
" return grad, hess\n",
|
||||
"\n",
|
||||
"# create customized XGBoost learners class with your objective function\n",
|
||||
"from flaml.model import XGBoostEstimator\n",
|
||||
"from flaml.automl.model import XGBoostEstimator\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class MyXGB1(XGBoostEstimator):\n",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"\n",
|
||||
"In this notebook, we use one real data example (binary classification) to showcase how to use FLAML library together with AzureML.\n",
|
||||
"\n",
|
||||
"FLAML requires `Python>=3.7`. To run this notebook example, please install flaml with the [automl,azureml] option:\n",
|
||||
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the [automl,azureml] option:\n",
|
||||
"```bash\n",
|
||||
"pip install flaml[automl,azureml]\n",
|
||||
"```"
|
||||
@@ -88,7 +88,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from flaml.data import load_openml_dataset\n",
|
||||
"from flaml.automl.data import load_openml_dataset\n",
|
||||
"X_train, X_test, y_train, y_test = load_openml_dataset(dataset_id=1169, data_dir='./')"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -12,6 +13,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -40,7 +42,7 @@
|
||||
"\n",
|
||||
"In this notebook, we use one real data example (binary classification) to showcase how to use FLAML library.\n",
|
||||
"\n",
|
||||
"FLAML requires `Python>=3.7`. To run this notebook example, please install flaml with the `[automl]` option (this option is introduced from version 2, for version 1 it is installed by default):\n",
|
||||
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the `[automl]` option (this option is introduced from version 2, for version 1 it is installed by default):\n",
|
||||
"```bash\n",
|
||||
"pip install flaml[automl]\n",
|
||||
"```"
|
||||
@@ -56,6 +58,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -76,6 +79,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -83,6 +87,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -109,7 +114,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from flaml.data import load_openml_dataset\n",
|
||||
"from flaml.automl.data import load_openml_dataset\n",
|
||||
"X_train, X_test, y_train, y_test = load_openml_dataset(\n",
|
||||
" dataset_id=1169, data_dir='./', random_state=1234, dataset_format='array')"
|
||||
]
|
||||
@@ -135,6 +140,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -232,6 +238,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
@@ -449,7 +456,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<flaml.model.XGBoostSklearnEstimator at 0x7f03a5eada00>"
|
||||
"<flaml.automl.model.XGBoostSklearnEstimator at 0x7f03a5eada00>"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
@@ -462,6 +469,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user