Update README.md
Browse files
README.md
CHANGED
|
@@ -103,12 +103,23 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 103 |
device = "cuda"
|
| 104 |
model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-code-to-doc-1.3b").to(device)
|
| 105 |
tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-code-to-doc-1.3b")
|
| 106 |
-
prompt = f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
<function_code>
|
| 108 |
def example_function(x):
|
| 109 |
return x * 2
|
| 110 |
</function_code>
|
| 111 |
-
<question>
|
| 112 |
<doc>"""
|
| 113 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 114 |
outputs = model.generate(**inputs, max_new_tokens=300)
|
|
@@ -121,95 +132,85 @@ tokenizer.decode(outputs[0], skip_special_tokens=True).split('<doc>')[-1].split(
|
|
| 121 |
|
| 122 |
### prompt
|
| 123 |
```python
|
| 124 |
-
<
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
#
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
np_array_H_matrix[i][j] = (np_array_Z_matrix[j][j] - np_array_Z_matrix[i][j])/np_array_perron_frobenius_vector[j]
|
| 191 |
-
print('np_array_H_matrix:')
|
| 192 |
-
print(np_array_H_matrix)
|
| 193 |
-
print('\n\n')
|
| 194 |
-
return np_array_H_matrix
|
| 195 |
-
###########
|
| 196 |
-
# func: run
|
| 197 |
-
###########
|
| 198 |
-
def run(np_array_A_matrix):
|
| 199 |
-
int_num_states = len(np_array_A_matrix)
|
| 200 |
-
np_array_P_matrix = get_np_array_transition_probability_matrix(int_num_states, np_array_A_matrix)
|
| 201 |
-
np_array_perron_frobenius_vector, np_array_perron_frobenius_matrix = get_np_array_perron_frobenius_matrix(int_num_states, np_array_P_matrix)
|
| 202 |
-
np_array_Z_matrix = get_np_array_Z_matrix(int_num_states, np_array_P_matrix, np_array_perron_frobenius_matrix)
|
| 203 |
-
np_array_H_matrix = get_np_array_H_matrix(int_num_states, np_array_Z_matrix, np_array_perron_frobenius_vector)
|
| 204 |
-
return(np_array_H_matrix)
|
| 205 |
-
</function_code>
|
| 206 |
-
<question>Give one line description of the python code above in natural language.</question>
|
| 207 |
-
<doc>
|
| 208 |
```
|
| 209 |
|
| 210 |
### Response
|
| 211 |
```txt
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
```
|
| 214 |
|
| 215 |
### Team
|
|
|
|
| 103 |
device = "cuda"
|
| 104 |
model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-code-to-doc-1.3b").to(device)
|
| 105 |
tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-code-to-doc-1.3b")
|
| 106 |
+
prompt = f"""<example_response>
|
| 107 |
+
--code:def function_2(x): return x / 2
|
| 108 |
+
--question:Document the code
|
| 109 |
+
--doc:
|
| 110 |
+
Description:This function takes a number and divides it by 2.
|
| 111 |
+
Parameters:
|
| 112 |
+
- x (numeric): The input value to be divided by 2.
|
| 113 |
+
Returns:
|
| 114 |
+
- float: The result of x divided by 2
|
| 115 |
+
Example:
|
| 116 |
+
To call the function, use the following code:
|
| 117 |
+
function2(1.0)</example_response>
|
| 118 |
<function_code>
|
| 119 |
def example_function(x):
|
| 120 |
return x * 2
|
| 121 |
</function_code>
|
| 122 |
+
<question>Document the python code above giving function description ,parameters and return type and example how to call the function.</question>
|
| 123 |
<doc>"""
|
| 124 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 125 |
outputs = model.generate(**inputs, max_new_tokens=300)
|
|
|
|
| 132 |
|
| 133 |
### prompt
|
| 134 |
```python
|
| 135 |
+
text=''' <example_response>
|
| 136 |
+
--code:def function_2(x): return x / 2
|
| 137 |
+
--question:Document the code
|
| 138 |
+
--doc:
|
| 139 |
+
Description:This function takes a number and divides it by 2.
|
| 140 |
+
Parameters:
|
| 141 |
+
- x (numeric): The input value to be divided by 2.
|
| 142 |
+
Returns:
|
| 143 |
+
- float: The result of x divided by 2
|
| 144 |
+
Example:
|
| 145 |
+
To call the function, use the following code:
|
| 146 |
+
function2(1.0)</example_response>
|
| 147 |
+
<function_code>def _plot_bounding_polygon(
|
| 148 |
+
polygons_coordinates, output_html_path="bounding_polygon_map.html"
|
| 149 |
+
):
|
| 150 |
+
# Create a Folium map centered at the average coordinates of all bounding boxes
|
| 151 |
+
map_center = [
|
| 152 |
+
sum(
|
| 153 |
+
[
|
| 154 |
+
coord[0]
|
| 155 |
+
for polygon_coords in polygons_coordinates
|
| 156 |
+
for coord in polygon_coords
|
| 157 |
+
]
|
| 158 |
+
)
|
| 159 |
+
/ sum([len(polygon_coords) for polygon_coords in polygons_coordinates]),
|
| 160 |
+
sum(
|
| 161 |
+
[
|
| 162 |
+
coord[1]
|
| 163 |
+
for polygon_coords in polygons_coordinates
|
| 164 |
+
for coord in polygon_coords
|
| 165 |
+
]
|
| 166 |
+
)
|
| 167 |
+
/ sum([len(polygon_coords) for polygon_coords in polygons_coordinates]),
|
| 168 |
+
]
|
| 169 |
+
|
| 170 |
+
my_map = folium.Map(location=map_center, zoom_start=12)
|
| 171 |
+
|
| 172 |
+
# Add each bounding polygon to the map
|
| 173 |
+
for polygon_coords in polygons_coordinates:
|
| 174 |
+
folium.Polygon(
|
| 175 |
+
locations=polygon_coords,
|
| 176 |
+
color="blue",
|
| 177 |
+
fill=True,
|
| 178 |
+
fill_color="blue",
|
| 179 |
+
fill_opacity=0.2,
|
| 180 |
+
).add_to(my_map)
|
| 181 |
+
|
| 182 |
+
# Add bounding boxes as markers to the map
|
| 183 |
+
marker_cluster = MarkerCluster().add_to(my_map)
|
| 184 |
+
|
| 185 |
+
for polygon_coords in polygons_coordinates:
|
| 186 |
+
for coord in polygon_coords:
|
| 187 |
+
folium.Marker(
|
| 188 |
+
location=[coord[0], coord[1]], popup=f"Coordinates: {coord}"
|
| 189 |
+
).add_to(marker_cluster)
|
| 190 |
+
|
| 191 |
+
# Add draw control to allow users to draw additional polygons
|
| 192 |
+
draw = Draw(export=True)
|
| 193 |
+
draw.add_to(my_map)
|
| 194 |
+
|
| 195 |
+
# Save the map as an HTML file
|
| 196 |
+
my_map.save(output_html_path)
|
| 197 |
+
|
| 198 |
+
return output_html_path
|
| 199 |
+
</function_code>
|
| 200 |
+
<question>Document the python code above giving function description ,parameters and return type and example how to call the function</question><doc>'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
```
|
| 202 |
|
| 203 |
### Response
|
| 204 |
```txt
|
| 205 |
+
Description:This function generates a map of the bounding polygons and saves it as an HTML file.
|
| 206 |
+
Parameters:
|
| 207 |
+
- polygons_coordinates (list of lists of tuples): A list of lists of tuples representing the coordinates of the polygons. Each polygon is a list of coordinates.
|
| 208 |
+
- output_html_path (str, optional): The path where the HTML file should be saved. Defaults to "bounding_polygon_map.html".
|
| 209 |
+
Returns:
|
| 210 |
+
- str: The path to the saved HTML file.
|
| 211 |
+
Example:
|
| 212 |
+
To call the function, use the following code:
|
| 213 |
+
plot_bounding_polygon([[(0, 0), (1, 0), (1, 1), (0, 1)], [(2, 2), (3, 2), (3, 3), (2, 3)]], "my_map.html").
|
| 214 |
```
|
| 215 |
|
| 216 |
### Team
|