m-ric HF staff commited on
Commit
5622e1c
1 Parent(s): a8ce2d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -75,31 +75,47 @@ def chunk(text, length, splitter_selection, separators_str, length_unit_selectio
75
  return output
76
 
77
 
78
- ESSAY = """Chapter 6
79
 
80
  WHAT SORT OF DESPOTISM DEMOCRATIC NATIONS HAVE TO FEAR
81
 
82
  I had remarked during my stay in the United States that a democratic state of society, similar to that of the Americans, might offer singular facilities for the establishment of despotism; and I perceived, upon my return to Europe, how much use had already been made, by most of our rulers, of the notions, the sentiments, and the wants created by this same social condition, for the purpose of extending the circle of their power. This led me to think that the nations of Christendom would perhaps eventually undergo some oppression like that which hung over several of the nations of the ancient world.
83
  A more accurate examination of the subject, and five years of further meditation, have not diminished my fears, but have changed their object.
84
  No sovereign ever lived in former ages so absolute or so powerful as to undertake to administer by his own agency, and without the assistance of intermediate powers, all the parts of a great empire; none ever attempted to subject all his subjects indiscriminately to strict uniformity of regulation and personally to tutor and direct every member of the community. The notion of such an undertaking never occurred to the human mind; and if any man had conceived it, the want of information, the imperfection of the administrative system, and, above all, the natural obstacles caused by the inequality of conditions would speedily have checked the execution of so vast a design.
85
- When the Roman emperors were at the height of their power, the different nations of the empire still preserved usages and customs of great diversity; although they were subject to the same monarch, most of the provinces were separately administered; they abounded in powerful and active municipalities; and although the whole government of the empire was centered in the hands of the Emperor alone and he always remained, in case of need, the supreme arbiter in all matters, yet the details of social life and private occupations lay for the most part beyond his control. The emperors possessed, it is true, an immense and unchecked power, which allowed them to gratify all their whimsical tastes and to employ for that purpose the whole strength of the state. They frequently abused that power arbitrarily to deprive their subjects of property or of life; their tyranny was extremely onerous to the few, but it did not reach the many; it was confined to some few main objects and neglected the rest; it was violent, but its range was limited.
86
 
87
  ---
88
 
89
- Then you can [Create a dataset repository](../huggingface_hub/quick-start#create-a-repository), for example using:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  ```python
92
- from huggingface_hub import HfApi
93
- HfApi().create_repo(repo_id="username/my_dataset", repo_type="dataset")
94
- ```
95
- Finally, you can use [Hugging Face paths]([Hugging Face paths](https://huggingface.co/docs/huggingface_hub/guides/hf_file_system#integrations)) in Pandas:
96
- ```python
97
- import pandas as pd
98
- df.to_parquet("hf://datasets/username/my_dataset/data.parquet")
99
- # or write in separate files if the dataset has train/validation/test splits
100
- df_train.to_parquet("hf://datasets/username/my_dataset/train.parquet")
101
- df_valid.to_parquet("hf://datasets/username/my_dataset/validation.parquet")
102
- df_test .to_parquet("hf://datasets/username/my_dataset/test.parquet")
103
  ```
104
  """
105
 
 
75
  return output
76
 
77
 
78
+ ESSAY = """### Chapter 6
79
 
80
  WHAT SORT OF DESPOTISM DEMOCRATIC NATIONS HAVE TO FEAR
81
 
82
  I had remarked during my stay in the United States that a democratic state of society, similar to that of the Americans, might offer singular facilities for the establishment of despotism; and I perceived, upon my return to Europe, how much use had already been made, by most of our rulers, of the notions, the sentiments, and the wants created by this same social condition, for the purpose of extending the circle of their power. This led me to think that the nations of Christendom would perhaps eventually undergo some oppression like that which hung over several of the nations of the ancient world.
83
  A more accurate examination of the subject, and five years of further meditation, have not diminished my fears, but have changed their object.
84
  No sovereign ever lived in former ages so absolute or so powerful as to undertake to administer by his own agency, and without the assistance of intermediate powers, all the parts of a great empire; none ever attempted to subject all his subjects indiscriminately to strict uniformity of regulation and personally to tutor and direct every member of the community. The notion of such an undertaking never occurred to the human mind; and if any man had conceived it, the want of information, the imperfection of the administrative system, and, above all, the natural obstacles caused by the inequality of conditions would speedily have checked the execution of so vast a design.
 
85
 
86
  ---
87
 
88
+
89
+ ### Challenges of agent systems
90
+
91
+ Generally, the difficult parts of running an agent system for the LLM engine are:
92
+
93
+ 1. From supplied tools, choose the one that will help advance to a desired goal: e.g. when asked `"What is the smallest prime number greater than 30,000?"`, the agent could call the `Search` tool with `"What is he height of K2"` but it won't help.
94
+ 2. Call tools with a rigorous argument formatting: for instance when trying to calculate the speed of a car that went 3 km in 10 minutes, you have to call tool `Calculator` to divide `distance` by `time` : even if your Calculator tool accepts calls in the JSON format: `{”tool”: “Calculator”, “args”: “3km/10min”}` , there are many pitfalls, for instance:
95
+ - Misspelling the tool name: `“calculator”` or `“Compute”` wouldn’t work
96
+ - Giving the name of the arguments instead of their values: `“args”: “distance/time”`
97
+ - Non-standardized formatting: `“args": "3km in 10minutes”`
98
+ 3. Efficiently ingesting and using the information gathered in the past observations, be it the initial context or the observations returned after using tool uses.
99
+
100
+
101
+ So, how would a complete Agent setup look like?
102
+
103
+ ## Running agents with LangChain
104
+
105
+ We have just integrated a `ChatHuggingFace` wrapper that lets you create agents based on open-source models in [🦜🔗LangChain](https://www.langchain.com/).
106
+
107
+ The code to create the ChatModel and give it tools is really simple, you can check it all in the [Langchain doc](https://python.langchain.com/docs/integrations/chat/huggingface).
108
 
109
  ```python
110
+ from langchain_community.llms import HuggingFaceHub
111
+ from langchain_community.chat_models.huggingface import ChatHuggingFace
112
+
113
+ llm = HuggingFaceHub(
114
+ repo_id="HuggingFaceH4/zephyr-7b-beta",
115
+ task="text-generation",
116
+ )
117
+
118
+ chat_model = ChatHuggingFace(llm=llm)
 
 
119
  ```
120
  """
121